Reputation: 99
This is my code
$('#txt_street').typeahead({
autoSelect:false,
ajax: {
url: "/index.php/MyCities/get_myCities/",
timeout: 500,
async : false,
displayField: "city_name",
valueField: 'city_id',
triggerLength: 1,
method: "get",
loadingClass: "loading-circle",
preDispatch: function (query) {
return {
search: query
}
},
preProcess: function (data) {
return data;
}
},
onSelect: function (citySelect) {
} //on select end
}); //city typeahead ends
I have two questions:
Upvotes: 0
Views: 1457
Reputation: 5745
You can add another parameter in preDispatch
and create your ajax URL before call typeahead()
For more get:
myUrl = "http://yoursite.com/" + yourdata; //Here your custom url
$('#txt_street').typeahead({
autoSelect:false,
ajax: {
url: myUrl , // Your custom url
timeout: 500,
async : false,
displayField: "city_name",
valueField: 'city_id',
triggerLength: 1,
method: "get",
loadingClass: "loading-circle",
preDispatch: function (query) {
return {
search: query,
otherParam: 123 //Other parameter get you want
}
},
preProcess: function (data) {
return data;
}
},
onSelect: function (citySelect) {
} //on select end
}); //city typeahead ends
See more here : https://github.com/pwarelis/Ajax-Typeahead
Upvotes: 3