jQuery UI Auto Complete : Issue with Custom Data fetching -
i trying demo jquery ui on own project , found 1 essential modification in need it. see on below demo :
http://jqueryui.com/demos/autocomplete/#custom-data
in example, when type "j" , select 1 option, fetch text , logo related it. working fine. here, lets select "jquery" auto-suggestions given. load text , jquery logo on left side. suppose after doing this, if delete characters of word "jquery" textbox should reset , display blank outputs. remains same text , logo loaded previously.
in general, want is, user must select autosuggestion , not write not in auto suggestions give.
how can that?
thanks in advance.
you can override select , change event achieve this:
$(".combobox").autocomplete({ minlength: 0, source: function (request, respond) { //some source }, change: function (event, ui) { //if no value inside li, reset input -> uses custom selector if ($(".ui-autocomplete li:textequals('" + $(this).val() + "')").size() == 0) { $(this).val(''); }, select: function (event, ui) { $(this).val(ui.item.name); } );
you need custom selector compare text-input:
$.expr[':'].textequals = function (a, i, m) { return $(a).text().match("^" + m[3] + "$"); };
Comments
Post a Comment