Display jquery ui autocomplete with categories horizontally and not verticallyIs there an “exists” function for jQuery?Add table row in jQueryHow do I check if an element is hidden in jQuery?Setting “checked” for a checkbox with jQuery?How can I know which radio button is selected via jQuery?How to check whether a checkbox is checked in jQuery?Disable/enable an input with jQuery?How can I refresh a page with jQuery?jQuery scroll to element“Thinking in AngularJS” if I have a jQuery background?

How can I use my cell phone's light as a reading light?

Was the 45.9°C temperature in France in June 2019 the highest ever recorded in France?

How do ballistic trajectories work in a ring world?

What was the nature of the known bugs in the Space Shuttle software?

What was the significance of Spider-Man: Far From Home being an MCU Phase 3 film instead of a Phase 4 film?

What exactly is a "murder hobo"?

Why do Martians have to wear space helmets?

Is this car delivery via Ebay Motors on Craigslist a scam?

How was the website able to tell my credit card was wrong before it processed it?

I'm feeling like my character doesn't fit the campaign

Function that detects repetitions

Wouldn't putting an electronic key inside a small Faraday cage render it completely useless?

Attach a visible light telescope to the outside of the ISS

Sense of humor in your sci-fi stories

My professor has told me he will be the corresponding author. Will it hurt my future career?

Why did the frequency of the word "черт" (devil) in books increase by a few times since the October Revolution?

Can we share mixing jug/beaker for developer, fixer and stop bath?

Can a USB hub be used to access a drive from two devices?

How would a sea turtle end up on its back?

Shipped package arrived - didn't order, possible scam?

What was the coded message that Happy Hogan sent to Nick Fury?

Why do most airliners have underwing engines, while business jets have rear-mounted engines?

What are some bad ways to subvert tropes?

How did the IEC decide to create kibibytes?



Display jquery ui autocomplete with categories horizontally and not vertically


Is there an “exists” function for jQuery?Add table row in jQueryHow do I check if an element is hidden in jQuery?Setting “checked” for a checkbox with jQuery?How can I know which radio button is selected via jQuery?How to check whether a checkbox is checked in jQuery?Disable/enable an input with jQuery?How can I refresh a page with jQuery?jQuery scroll to element“Thinking in AngularJS” if I have a jQuery background?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am trying to display the autocomplete results horizontally instead of the default(vertical). I was able to do it but the issue is I cant select the item from the drop down anymore. I think because I used div instead of ul. And if I use ul jquery appends some un-wanted classes inline. Which messes up the horizontal behaviour



HTML



 <label for="search">Search: </label>
<input id="search">


CSS



#search 
width: 500px;

.ui-autocomplete
display: flex;
width: auto !important;


.ui-autocomplete-category
font-weight: bold;
padding: .2em .4em;
margin: .8em 0 .2em;
line-height: 1.5;

.ui-autocomplete-category ul
padding:0;

.submenu
font-weight: normal;



JS



$.widget( "custom.catcomplete", $.ui.autocomplete, 
_create: function()
this._super();
this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
,
_renderMenu: function( ul, items )
var that = this,
currentCategory = "";
$.each( items, function( index, item )
var li, submenuUl;
if ( item.category != currentCategory )
var elt = $("<li class='ui-autocomplete-category'>" + item.category + "</li>");
var submenu = $("<div class='submenu "+ item.category +"'></div>");
elt.append(submenu);
ul.append(elt);
currentCategory = item.category;

submenuUl = ul.find("."+item.category+"");
li = that._renderItemData(submenuUl, item );
if ( item.category )
li.attr( "aria-label", item.category + " : " + item.label );

);

);


https://codepen.io/nitinmendiratta/pen/aMMeOz










share|improve this question




























    0















    I am trying to display the autocomplete results horizontally instead of the default(vertical). I was able to do it but the issue is I cant select the item from the drop down anymore. I think because I used div instead of ul. And if I use ul jquery appends some un-wanted classes inline. Which messes up the horizontal behaviour



    HTML



     <label for="search">Search: </label>
    <input id="search">


    CSS



    #search 
    width: 500px;

    .ui-autocomplete
    display: flex;
    width: auto !important;


    .ui-autocomplete-category
    font-weight: bold;
    padding: .2em .4em;
    margin: .8em 0 .2em;
    line-height: 1.5;

    .ui-autocomplete-category ul
    padding:0;

    .submenu
    font-weight: normal;



    JS



    $.widget( "custom.catcomplete", $.ui.autocomplete, 
    _create: function()
    this._super();
    this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
    ,
    _renderMenu: function( ul, items )
    var that = this,
    currentCategory = "";
    $.each( items, function( index, item )
    var li, submenuUl;
    if ( item.category != currentCategory )
    var elt = $("<li class='ui-autocomplete-category'>" + item.category + "</li>");
    var submenu = $("<div class='submenu "+ item.category +"'></div>");
    elt.append(submenu);
    ul.append(elt);
    currentCategory = item.category;

    submenuUl = ul.find("."+item.category+"");
    li = that._renderItemData(submenuUl, item );
    if ( item.category )
    li.attr( "aria-label", item.category + " : " + item.label );

    );

    );


    https://codepen.io/nitinmendiratta/pen/aMMeOz










    share|improve this question
























      0












      0








      0








      I am trying to display the autocomplete results horizontally instead of the default(vertical). I was able to do it but the issue is I cant select the item from the drop down anymore. I think because I used div instead of ul. And if I use ul jquery appends some un-wanted classes inline. Which messes up the horizontal behaviour



      HTML



       <label for="search">Search: </label>
      <input id="search">


      CSS



      #search 
      width: 500px;

      .ui-autocomplete
      display: flex;
      width: auto !important;


      .ui-autocomplete-category
      font-weight: bold;
      padding: .2em .4em;
      margin: .8em 0 .2em;
      line-height: 1.5;

      .ui-autocomplete-category ul
      padding:0;

      .submenu
      font-weight: normal;



      JS



      $.widget( "custom.catcomplete", $.ui.autocomplete, 
      _create: function()
      this._super();
      this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
      ,
      _renderMenu: function( ul, items )
      var that = this,
      currentCategory = "";
      $.each( items, function( index, item )
      var li, submenuUl;
      if ( item.category != currentCategory )
      var elt = $("<li class='ui-autocomplete-category'>" + item.category + "</li>");
      var submenu = $("<div class='submenu "+ item.category +"'></div>");
      elt.append(submenu);
      ul.append(elt);
      currentCategory = item.category;

      submenuUl = ul.find("."+item.category+"");
      li = that._renderItemData(submenuUl, item );
      if ( item.category )
      li.attr( "aria-label", item.category + " : " + item.label );

      );

      );


      https://codepen.io/nitinmendiratta/pen/aMMeOz










      share|improve this question














      I am trying to display the autocomplete results horizontally instead of the default(vertical). I was able to do it but the issue is I cant select the item from the drop down anymore. I think because I used div instead of ul. And if I use ul jquery appends some un-wanted classes inline. Which messes up the horizontal behaviour



      HTML



       <label for="search">Search: </label>
      <input id="search">


      CSS



      #search 
      width: 500px;

      .ui-autocomplete
      display: flex;
      width: auto !important;


      .ui-autocomplete-category
      font-weight: bold;
      padding: .2em .4em;
      margin: .8em 0 .2em;
      line-height: 1.5;

      .ui-autocomplete-category ul
      padding:0;

      .submenu
      font-weight: normal;



      JS



      $.widget( "custom.catcomplete", $.ui.autocomplete, 
      _create: function()
      this._super();
      this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
      ,
      _renderMenu: function( ul, items )
      var that = this,
      currentCategory = "";
      $.each( items, function( index, item )
      var li, submenuUl;
      if ( item.category != currentCategory )
      var elt = $("<li class='ui-autocomplete-category'>" + item.category + "</li>");
      var submenu = $("<div class='submenu "+ item.category +"'></div>");
      elt.append(submenu);
      ul.append(elt);
      currentCategory = item.category;

      submenuUl = ul.find("."+item.category+"");
      li = that._renderItemData(submenuUl, item );
      if ( item.category )
      li.attr( "aria-label", item.category + " : " + item.label );

      );

      );


      https://codepen.io/nitinmendiratta/pen/aMMeOz







      jquery jquery-ui-autocomplete






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 21:17









      Nitin MendirattaNitin Mendiratta

      234 bronze badges




      234 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          1














          That is widget tweeking I like!



          The main mistake was not having a ul as direct parent of your custom li.

          Then, Those custom li need the ui-menu-item class in order to be selected...



          Lastly, you have to "override" the styling of the nested ul using !important. So they will be displayed as block with a relative position. Incidentally, without border...



          And I removed an icon strangely showing...



          It works fine in CodePen. It needed an additional CSS rule to work in the below snippet. (Don't ask me why!)






          $.widget( "custom.catcomplete", $.ui.autocomplete, 
          _create: function()
          this._super();
          this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
          ,
          _renderMenu: function( ul, items )
          var that = this,
          currentCategory = "";
          $.each( items, function( index, item )
          var li, submenuUl;
          if ( item.category != currentCategory )
          var elt = $("<li class='ui-autocomplete-category'>" + item.category + "</li>");
          var submenu = $("<div class='submenu "+ item.category +"'><ul></ul></div>"); // Added <ul></ul>
          elt.append(submenu);
          ul.append(elt);
          currentCategory = item.category;

          submenuUl = ul.find("."+item.category+" ul"); // added +" ul"
          li = that._renderItemData(submenuUl, item );
          if ( item.category )
          li.attr( "aria-label", item.category + " : " + item.label ).addClass("ui-menu-item"); // Added the addClass()

          );

          );


          // Actual Code
          $(function()
          var data = [
          label: "annhhx10", category: "Products" ,
          label: "annk K12", category: "Products" ,
          label: "annttop C13", category: "Products" ,
          label: "anders andersson", category: "People" ,
          label: "andreas andersson", category: "People" ,
          label: "andreas johnson", category: "People"
          ];

          $( "#search" ).catcomplete(
          delay: 0,
          source: data,
          select: function(item, ui) // Added item, ui --- Arguments were missing.
          console.log(ui.item.value);
          $( "#search" ).val( ui.item.value );
          return false;

          );
          );

          #search 
          width: 500px;

          .ui-autocomplete
          display: flex;
          width: auto !important;


          .ui-autocomplete-category
          font-weight: bold;
          padding: .2em .4em;
          margin: .8em 0 .2em;
          line-height: 1.5;

          .ui-autocomplete-category ul
          padding:0;

          .submenu
          font-weight: normal;


          /* ADDED STYLE */
          .ui-autocomplete>li>div>ul
          display: block !important;
          position: relative !important;
          border: 0 !important;

          span.ui-menu-icon
          display:none !important;


          /* ADDED for the SO snippet only !! Not needed on CodePen */
          .ui-autocomplete>li
          display: inline-block !important;

          <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
          <script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
          <link href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>

          <label for="search">Search: </label>
          <input id="search">








          share|improve this answer























          • Thanks a lot it is working as expected. Appreciate it :)

            – Nitin Mendiratta
            Mar 26 at 13:30










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55346534%2fdisplay-jquery-ui-autocomplete-with-categories-horizontally-and-not-vertically%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          That is widget tweeking I like!



          The main mistake was not having a ul as direct parent of your custom li.

          Then, Those custom li need the ui-menu-item class in order to be selected...



          Lastly, you have to "override" the styling of the nested ul using !important. So they will be displayed as block with a relative position. Incidentally, without border...



          And I removed an icon strangely showing...



          It works fine in CodePen. It needed an additional CSS rule to work in the below snippet. (Don't ask me why!)






          $.widget( "custom.catcomplete", $.ui.autocomplete, 
          _create: function()
          this._super();
          this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
          ,
          _renderMenu: function( ul, items )
          var that = this,
          currentCategory = "";
          $.each( items, function( index, item )
          var li, submenuUl;
          if ( item.category != currentCategory )
          var elt = $("<li class='ui-autocomplete-category'>" + item.category + "</li>");
          var submenu = $("<div class='submenu "+ item.category +"'><ul></ul></div>"); // Added <ul></ul>
          elt.append(submenu);
          ul.append(elt);
          currentCategory = item.category;

          submenuUl = ul.find("."+item.category+" ul"); // added +" ul"
          li = that._renderItemData(submenuUl, item );
          if ( item.category )
          li.attr( "aria-label", item.category + " : " + item.label ).addClass("ui-menu-item"); // Added the addClass()

          );

          );


          // Actual Code
          $(function()
          var data = [
          label: "annhhx10", category: "Products" ,
          label: "annk K12", category: "Products" ,
          label: "annttop C13", category: "Products" ,
          label: "anders andersson", category: "People" ,
          label: "andreas andersson", category: "People" ,
          label: "andreas johnson", category: "People"
          ];

          $( "#search" ).catcomplete(
          delay: 0,
          source: data,
          select: function(item, ui) // Added item, ui --- Arguments were missing.
          console.log(ui.item.value);
          $( "#search" ).val( ui.item.value );
          return false;

          );
          );

          #search 
          width: 500px;

          .ui-autocomplete
          display: flex;
          width: auto !important;


          .ui-autocomplete-category
          font-weight: bold;
          padding: .2em .4em;
          margin: .8em 0 .2em;
          line-height: 1.5;

          .ui-autocomplete-category ul
          padding:0;

          .submenu
          font-weight: normal;


          /* ADDED STYLE */
          .ui-autocomplete>li>div>ul
          display: block !important;
          position: relative !important;
          border: 0 !important;

          span.ui-menu-icon
          display:none !important;


          /* ADDED for the SO snippet only !! Not needed on CodePen */
          .ui-autocomplete>li
          display: inline-block !important;

          <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
          <script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
          <link href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>

          <label for="search">Search: </label>
          <input id="search">








          share|improve this answer























          • Thanks a lot it is working as expected. Appreciate it :)

            – Nitin Mendiratta
            Mar 26 at 13:30















          1














          That is widget tweeking I like!



          The main mistake was not having a ul as direct parent of your custom li.

          Then, Those custom li need the ui-menu-item class in order to be selected...



          Lastly, you have to "override" the styling of the nested ul using !important. So they will be displayed as block with a relative position. Incidentally, without border...



          And I removed an icon strangely showing...



          It works fine in CodePen. It needed an additional CSS rule to work in the below snippet. (Don't ask me why!)






          $.widget( "custom.catcomplete", $.ui.autocomplete, 
          _create: function()
          this._super();
          this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
          ,
          _renderMenu: function( ul, items )
          var that = this,
          currentCategory = "";
          $.each( items, function( index, item )
          var li, submenuUl;
          if ( item.category != currentCategory )
          var elt = $("<li class='ui-autocomplete-category'>" + item.category + "</li>");
          var submenu = $("<div class='submenu "+ item.category +"'><ul></ul></div>"); // Added <ul></ul>
          elt.append(submenu);
          ul.append(elt);
          currentCategory = item.category;

          submenuUl = ul.find("."+item.category+" ul"); // added +" ul"
          li = that._renderItemData(submenuUl, item );
          if ( item.category )
          li.attr( "aria-label", item.category + " : " + item.label ).addClass("ui-menu-item"); // Added the addClass()

          );

          );


          // Actual Code
          $(function()
          var data = [
          label: "annhhx10", category: "Products" ,
          label: "annk K12", category: "Products" ,
          label: "annttop C13", category: "Products" ,
          label: "anders andersson", category: "People" ,
          label: "andreas andersson", category: "People" ,
          label: "andreas johnson", category: "People"
          ];

          $( "#search" ).catcomplete(
          delay: 0,
          source: data,
          select: function(item, ui) // Added item, ui --- Arguments were missing.
          console.log(ui.item.value);
          $( "#search" ).val( ui.item.value );
          return false;

          );
          );

          #search 
          width: 500px;

          .ui-autocomplete
          display: flex;
          width: auto !important;


          .ui-autocomplete-category
          font-weight: bold;
          padding: .2em .4em;
          margin: .8em 0 .2em;
          line-height: 1.5;

          .ui-autocomplete-category ul
          padding:0;

          .submenu
          font-weight: normal;


          /* ADDED STYLE */
          .ui-autocomplete>li>div>ul
          display: block !important;
          position: relative !important;
          border: 0 !important;

          span.ui-menu-icon
          display:none !important;


          /* ADDED for the SO snippet only !! Not needed on CodePen */
          .ui-autocomplete>li
          display: inline-block !important;

          <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
          <script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
          <link href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>

          <label for="search">Search: </label>
          <input id="search">








          share|improve this answer























          • Thanks a lot it is working as expected. Appreciate it :)

            – Nitin Mendiratta
            Mar 26 at 13:30













          1












          1








          1







          That is widget tweeking I like!



          The main mistake was not having a ul as direct parent of your custom li.

          Then, Those custom li need the ui-menu-item class in order to be selected...



          Lastly, you have to "override" the styling of the nested ul using !important. So they will be displayed as block with a relative position. Incidentally, without border...



          And I removed an icon strangely showing...



          It works fine in CodePen. It needed an additional CSS rule to work in the below snippet. (Don't ask me why!)






          $.widget( "custom.catcomplete", $.ui.autocomplete, 
          _create: function()
          this._super();
          this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
          ,
          _renderMenu: function( ul, items )
          var that = this,
          currentCategory = "";
          $.each( items, function( index, item )
          var li, submenuUl;
          if ( item.category != currentCategory )
          var elt = $("<li class='ui-autocomplete-category'>" + item.category + "</li>");
          var submenu = $("<div class='submenu "+ item.category +"'><ul></ul></div>"); // Added <ul></ul>
          elt.append(submenu);
          ul.append(elt);
          currentCategory = item.category;

          submenuUl = ul.find("."+item.category+" ul"); // added +" ul"
          li = that._renderItemData(submenuUl, item );
          if ( item.category )
          li.attr( "aria-label", item.category + " : " + item.label ).addClass("ui-menu-item"); // Added the addClass()

          );

          );


          // Actual Code
          $(function()
          var data = [
          label: "annhhx10", category: "Products" ,
          label: "annk K12", category: "Products" ,
          label: "annttop C13", category: "Products" ,
          label: "anders andersson", category: "People" ,
          label: "andreas andersson", category: "People" ,
          label: "andreas johnson", category: "People"
          ];

          $( "#search" ).catcomplete(
          delay: 0,
          source: data,
          select: function(item, ui) // Added item, ui --- Arguments were missing.
          console.log(ui.item.value);
          $( "#search" ).val( ui.item.value );
          return false;

          );
          );

          #search 
          width: 500px;

          .ui-autocomplete
          display: flex;
          width: auto !important;


          .ui-autocomplete-category
          font-weight: bold;
          padding: .2em .4em;
          margin: .8em 0 .2em;
          line-height: 1.5;

          .ui-autocomplete-category ul
          padding:0;

          .submenu
          font-weight: normal;


          /* ADDED STYLE */
          .ui-autocomplete>li>div>ul
          display: block !important;
          position: relative !important;
          border: 0 !important;

          span.ui-menu-icon
          display:none !important;


          /* ADDED for the SO snippet only !! Not needed on CodePen */
          .ui-autocomplete>li
          display: inline-block !important;

          <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
          <script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
          <link href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>

          <label for="search">Search: </label>
          <input id="search">








          share|improve this answer













          That is widget tweeking I like!



          The main mistake was not having a ul as direct parent of your custom li.

          Then, Those custom li need the ui-menu-item class in order to be selected...



          Lastly, you have to "override" the styling of the nested ul using !important. So they will be displayed as block with a relative position. Incidentally, without border...



          And I removed an icon strangely showing...



          It works fine in CodePen. It needed an additional CSS rule to work in the below snippet. (Don't ask me why!)






          $.widget( "custom.catcomplete", $.ui.autocomplete, 
          _create: function()
          this._super();
          this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
          ,
          _renderMenu: function( ul, items )
          var that = this,
          currentCategory = "";
          $.each( items, function( index, item )
          var li, submenuUl;
          if ( item.category != currentCategory )
          var elt = $("<li class='ui-autocomplete-category'>" + item.category + "</li>");
          var submenu = $("<div class='submenu "+ item.category +"'><ul></ul></div>"); // Added <ul></ul>
          elt.append(submenu);
          ul.append(elt);
          currentCategory = item.category;

          submenuUl = ul.find("."+item.category+" ul"); // added +" ul"
          li = that._renderItemData(submenuUl, item );
          if ( item.category )
          li.attr( "aria-label", item.category + " : " + item.label ).addClass("ui-menu-item"); // Added the addClass()

          );

          );


          // Actual Code
          $(function()
          var data = [
          label: "annhhx10", category: "Products" ,
          label: "annk K12", category: "Products" ,
          label: "annttop C13", category: "Products" ,
          label: "anders andersson", category: "People" ,
          label: "andreas andersson", category: "People" ,
          label: "andreas johnson", category: "People"
          ];

          $( "#search" ).catcomplete(
          delay: 0,
          source: data,
          select: function(item, ui) // Added item, ui --- Arguments were missing.
          console.log(ui.item.value);
          $( "#search" ).val( ui.item.value );
          return false;

          );
          );

          #search 
          width: 500px;

          .ui-autocomplete
          display: flex;
          width: auto !important;


          .ui-autocomplete-category
          font-weight: bold;
          padding: .2em .4em;
          margin: .8em 0 .2em;
          line-height: 1.5;

          .ui-autocomplete-category ul
          padding:0;

          .submenu
          font-weight: normal;


          /* ADDED STYLE */
          .ui-autocomplete>li>div>ul
          display: block !important;
          position: relative !important;
          border: 0 !important;

          span.ui-menu-icon
          display:none !important;


          /* ADDED for the SO snippet only !! Not needed on CodePen */
          .ui-autocomplete>li
          display: inline-block !important;

          <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
          <script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
          <link href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>

          <label for="search">Search: </label>
          <input id="search">








          $.widget( "custom.catcomplete", $.ui.autocomplete, 
          _create: function()
          this._super();
          this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
          ,
          _renderMenu: function( ul, items )
          var that = this,
          currentCategory = "";
          $.each( items, function( index, item )
          var li, submenuUl;
          if ( item.category != currentCategory )
          var elt = $("<li class='ui-autocomplete-category'>" + item.category + "</li>");
          var submenu = $("<div class='submenu "+ item.category +"'><ul></ul></div>"); // Added <ul></ul>
          elt.append(submenu);
          ul.append(elt);
          currentCategory = item.category;

          submenuUl = ul.find("."+item.category+" ul"); // added +" ul"
          li = that._renderItemData(submenuUl, item );
          if ( item.category )
          li.attr( "aria-label", item.category + " : " + item.label ).addClass("ui-menu-item"); // Added the addClass()

          );

          );


          // Actual Code
          $(function()
          var data = [
          label: "annhhx10", category: "Products" ,
          label: "annk K12", category: "Products" ,
          label: "annttop C13", category: "Products" ,
          label: "anders andersson", category: "People" ,
          label: "andreas andersson", category: "People" ,
          label: "andreas johnson", category: "People"
          ];

          $( "#search" ).catcomplete(
          delay: 0,
          source: data,
          select: function(item, ui) // Added item, ui --- Arguments were missing.
          console.log(ui.item.value);
          $( "#search" ).val( ui.item.value );
          return false;

          );
          );

          #search 
          width: 500px;

          .ui-autocomplete
          display: flex;
          width: auto !important;


          .ui-autocomplete-category
          font-weight: bold;
          padding: .2em .4em;
          margin: .8em 0 .2em;
          line-height: 1.5;

          .ui-autocomplete-category ul
          padding:0;

          .submenu
          font-weight: normal;


          /* ADDED STYLE */
          .ui-autocomplete>li>div>ul
          display: block !important;
          position: relative !important;
          border: 0 !important;

          span.ui-menu-icon
          display:none !important;


          /* ADDED for the SO snippet only !! Not needed on CodePen */
          .ui-autocomplete>li
          display: inline-block !important;

          <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
          <script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
          <link href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>

          <label for="search">Search: </label>
          <input id="search">





          $.widget( "custom.catcomplete", $.ui.autocomplete, 
          _create: function()
          this._super();
          this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
          ,
          _renderMenu: function( ul, items )
          var that = this,
          currentCategory = "";
          $.each( items, function( index, item )
          var li, submenuUl;
          if ( item.category != currentCategory )
          var elt = $("<li class='ui-autocomplete-category'>" + item.category + "</li>");
          var submenu = $("<div class='submenu "+ item.category +"'><ul></ul></div>"); // Added <ul></ul>
          elt.append(submenu);
          ul.append(elt);
          currentCategory = item.category;

          submenuUl = ul.find("."+item.category+" ul"); // added +" ul"
          li = that._renderItemData(submenuUl, item );
          if ( item.category )
          li.attr( "aria-label", item.category + " : " + item.label ).addClass("ui-menu-item"); // Added the addClass()

          );

          );


          // Actual Code
          $(function()
          var data = [
          label: "annhhx10", category: "Products" ,
          label: "annk K12", category: "Products" ,
          label: "annttop C13", category: "Products" ,
          label: "anders andersson", category: "People" ,
          label: "andreas andersson", category: "People" ,
          label: "andreas johnson", category: "People"
          ];

          $( "#search" ).catcomplete(
          delay: 0,
          source: data,
          select: function(item, ui) // Added item, ui --- Arguments were missing.
          console.log(ui.item.value);
          $( "#search" ).val( ui.item.value );
          return false;

          );
          );

          #search 
          width: 500px;

          .ui-autocomplete
          display: flex;
          width: auto !important;


          .ui-autocomplete-category
          font-weight: bold;
          padding: .2em .4em;
          margin: .8em 0 .2em;
          line-height: 1.5;

          .ui-autocomplete-category ul
          padding:0;

          .submenu
          font-weight: normal;


          /* ADDED STYLE */
          .ui-autocomplete>li>div>ul
          display: block !important;
          position: relative !important;
          border: 0 !important;

          span.ui-menu-icon
          display:none !important;


          /* ADDED for the SO snippet only !! Not needed on CodePen */
          .ui-autocomplete>li
          display: inline-block !important;

          <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
          <script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
          <link href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>

          <label for="search">Search: </label>
          <input id="search">






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 25 at 22:26









          Louys Patrice BessetteLouys Patrice Bessette

          21.2k4 gold badges23 silver badges48 bronze badges




          21.2k4 gold badges23 silver badges48 bronze badges












          • Thanks a lot it is working as expected. Appreciate it :)

            – Nitin Mendiratta
            Mar 26 at 13:30

















          • Thanks a lot it is working as expected. Appreciate it :)

            – Nitin Mendiratta
            Mar 26 at 13:30
















          Thanks a lot it is working as expected. Appreciate it :)

          – Nitin Mendiratta
          Mar 26 at 13:30





          Thanks a lot it is working as expected. Appreciate it :)

          – Nitin Mendiratta
          Mar 26 at 13:30








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55346534%2fdisplay-jquery-ui-autocomplete-with-categories-horizontally-and-not-vertically%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해