Go4hosting




Go4hosting


return markup;
//]]>
}

function linkFormatSelection(link) {
return link.title;
}

var currEnteredData = null;

jQuery(document).ready(function($){
$(“#autoquery”).select2({
placeholder:”Search for a link”,
minimumInputLength:1,
ajax:{
url:servername,
dataType:’json’,
quietMillis:100,
allowClear:true,
data:function (term, page) { // page is the one-based page number tracked by Select2
return {
linkQuery: {q: term, loc: $(“#autoquery-location”).val()}, //search term
page_limit:100 // page size
};
},
results:function (data, page) {
// notice we return the value of more so Select2 knows if more results can be loaded
for (x in data.result) {
data.result[x].id = data.result[x].url;
}
data.result.unshift({‘id’:data.url, ‘title’:currEnteredData, ‘url’:’/search?search=’+currEnteredData})
return {results:data.result};
}
},

formatResult:linkFormatResult, // omitted for brevity, see the source of this page

formatSelection:linkFormatSelection // omitted for brevity, see the source of this page

}).on(‘change’, function(event){

document.location.href = $(this).val();

});

jQuery(“.select2-search input[type=’text’]”).keyup(function(event){
currEnteredData = jQuery(this).val();

});

jQuery(“#search_form”).submit(function(){
jQuery(“#autoquery”).val(currEnteredData);
});

});




Source link

We're happy to share this resource that we found. The content displayed on this page is property of it's original author and/or their organization.

Leave a Reply