Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.widget("custom.catcomplete", $.ui.autocomplete, {
- _renderMenu: function(ul, items) {
- var self = this,
- currentCategory = "";
- $.each(items, function(index, item) {
- //currentCategory = item.category;
- self._renderItem(ul, item, currentCategory);
- });
- },
- _renderItem: function(ul, item, currentCategory) {
- console.log(item.category + " || " + currentCategory)
- if (item.category && item.category != "" && item.category != currentCategory) {
- var leftDiv = $("<div class = 'customjQueryUILeftDiv'>" + item.category + "</div>")
- currentCategory = item.category;
- } else {
- leftDiv = ""
- }
- var rightDiv = $("<div class = 'customjQueryUIRightDiv'>" + item.label ? "<a>" + (item.label.trim() != "" ? item.label : " ") + (item.description ? "<p class='ui-autocomplete-description'>" + item.description + "</p>" : "") + "</a>" : "" + "</div>")
- return $("<li></li>")
- .data("item.autocomplete", item)
- .append(leftDiv)
- .append(rightDiv)
- .appendTo(ul);
- }
- });
Add Comment
Please, Sign In to add comment