Search Auto complete Jump Menu

Submitted by:Jhon Jhon

Date added:30 January, 2013

Category:jQuery

JQueryUI Search Auto complete Jump Menu with data from remote URL

Tags: jump menu , auto complete

Code Snippet:

jQuery(document).ready(function($) {
initialize();
// Load route data from a remote URL and store in a local JS variable
// We can then search this rather then hitting the backend onchange
var route_data = (function () {
var route_data = null;
$.ajax({
'async': false,
'global': false,
'url': "/route-search-autocomplete",
'dataType': "json",
'success': function (data) {
json = data;
}
});
return json;
})();

// Attach the route data to our route search box
$("#search-route-target").autocomplete({
source: route_data,
minLength: 3, // Activated on 3rd character
focus: function (event, ui) {
$(event.target).val(ui.item.label);
return false;
},
select: function (event, ui) {
$(event.target).val(ui.item.label);
window.location = ui.item.link;
return false;
}
});
});
 
 

Comments