|
1 |
[{"id":"aaa","id_and_ba_name":"bbb"}, ...] |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
var auto = $("#lc").autocomplete({
minLength: 3,
delay: 600,
dataType: 'json',
source: '/remote/action',
open: function() {
$("ul.ui-autocomplete").remove(); //removes the ul styling for dropdown
}
})
auto.data("autocomplete")._renderMenu= function(element, items) {
//treats the DOM element as the menu where items are to be placed
var self = this;
$('#the_select_element').show().html('');
$.each( items, function( index, item ) {
self._renderItem($('#the_select_element'), item );
});
}
auto.data("autocomplete")._renderItem= function(element, item) {
// generate options elements and adds them to menu
return $("<option></option>")
.data("item.autocomplete",item)
.attr("value",item.id)
.append(item.id_and_ba_name)
.appendTo(element);
} |
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.