How can I set extra parameters to the query like
q=myseed&filter=1,2,34
better will be with a attached event like
onFocus:function(){
//retrieve extra params
}
Here is a link to the plugin - http://loopj.com/jquery-tokeninput/
How can I set extra parameters to the query like
q=myseed&filter=1,2,34
better will be with a attached event like
onFocus:function(){
//retrieve extra params
}
Here is a link to the plugin - http://loopj.com/jquery-tokeninput/
Here is how you could do it, in the example below I am passing two extra param to the tokenInput url.
this.$("#abcTextbox").tokenInput("url?someParam1=cricket&someParam2=yasser", {
queryParam: "q"
});
another way to do it, you can use initial url to achieve this.
something like :
$("#selector").tokenInput("PATH_TO_SCRIPT&filter=1,2,3", {
queryParam: "q"
});
this will be processed as expected
PATH_TO_SCRIPT&filter=1,2,3?q=term to the serverI know that question is quite old but i had the same problem and found an answer.
Looking at the source, the url parameter can be a function that is evaled before sending the ajax query. So you can do :
this.$("#abcTextbox").tokenInput(function(){
return "/path/to/script.php?filter="+$("#myFieldId").val()
}, {
queryParam: "q"
...
});
This is possible by the plugin's native functionality(at least with the current version), it is just not written in the documentation: there is onSend callback in the code. Here is simple example
$(".my-input").tokenInput('autocomplete.php', {
hintText: false,
onSend: function(param1) {
// console.log($(this));
// console.log(param1);
param1.data.my_key = 'my_value';
}
});
Besides going into the actual plugin code and adding this feature the only other way I can see doing this is by changing the queryParam to something like -
filter=1,2,34&q
That way your filter is simply appended to the actual query parameter. It'd have to be hard coded and you will probably have to reinitialize the plugin every time you want to alter this additional filter.
Example -
$("#selector").tokenInput("PATH_TO_SCRIPT", {
queryParam: "filter=1,2,34&q"
});