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

          How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

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

          Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?