Bootstrap 3 typeahead.js - remote url attributes -


i'm trying call remote url added attributes url.

for have working:

$('#league').typeahead({         remote: '/typeahead/get_league?query=%query',         limit: 10 }); 

now this:

$('#league').typeahead({         remote: function () {             var q = '/typeahead/get_league?query=%query';             if ($('#sport').val())                 q += "&sport=" + encodeuricomponent($('#sport').val());             return base_url + q;         },         limit: 10 }); 

i add attribute 'sport' url can narrow down query on backend. tried code above js error.

the previous version of bootstrap typeahead allowed type of setup. useful update remote url every time key hit.

any idea how make work version ?

remote exclusively typeahead.js (not part of bootstrap). not using remote correctly, can either string or object, not function.

when need change request url, can use replace:

$('#league').typeahead({     remote: {         url: '/typeahead/get_league?query=%query',         replace: function () {             var q = '/typeahead/get_league?query=%query';             if ($('#sport').val()) {                 q += "&sport=" + encodeuricomponent($('#sport').val());             }             return base_url + q;         }     },     limit: 10  }); 

check docs here

hope helps.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -