Guest User

Untitled

a guest
May 27th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.25 KB | None | 0 0
  1. $.widget("custom.catcomplete", $.ui.autocomplete, {
  2.         _renderMenu: function(ul, items) {
  3.             var self = this,
  4.             currentCategory = "";
  5.             $.each(items, function(index, item) {
  6.                                 //currentCategory = item.category;
  7.                 self._renderItem(ul, item, currentCategory);
  8.             });
  9.         },
  10.                 _renderItem: function(ul, item, currentCategory) {
  11.                     console.log(item.category + " || " + currentCategory)
  12.                     if (item.category && item.category != "" && item.category != currentCategory) {
  13.                         var leftDiv = $("<div class = 'customjQueryUILeftDiv'>" + item.category + "</div>")
  14.                         currentCategory = item.category;
  15.                     } else {
  16.                         leftDiv = ""
  17.                     }
  18.                     var rightDiv = $("<div class = 'customjQueryUIRightDiv'>" + item.label ? "<a>" + (item.label.trim() != "" ? item.label : "&nbsp;") + (item.description ? "<p class='ui-autocomplete-description'>" + item.description + "</p>" : "") + "</a>" : "" + "</div>")
  19.                     return $("<li></li>")
  20.                     .data("item.autocomplete", item)
  21.                     .append(leftDiv)
  22.                     .append(rightDiv)
  23.                     .appendTo(ul);
  24.         }
  25.     });
Add Comment
Please, Sign In to add comment