The jquery tokeninput filter request sends additional parameters

How to set additional parameters for the request, for example

q=myseed&filter=1,2,34

it would be better with a related event like

onFocus:function(){
  //retrieve extra params
}

Here is the link to the plugin - http://loopj.com/jquery-tokeninput/

+5
source share
5 answers

Here is how you could do this, in the example below I am passing two additional parameters to the tokenInput url.

this.$("#abcTextbox").tokenInput("url?someParam1=cricket&someParam2=yasser", {
    queryParam: "q"
});

Source

+4
source

This is possible due to the built-in functionality of the plugin (at least with the current version), it is simply not written in the documentation: there is an onSend callback in the code. Here is a simple example

$(".my-input").tokenInput('autocomplete.php', {
    hintText: false,
    onSend: function(param1) {
        // console.log($(this));
        // console.log(param1);
        param1.data.my_key = 'my_value';
    }
});
+2
source

, , , queryParam - -

filter=1,2,34&q

, . , , , , .

-

$("#selector").tokenInput("PATH_TO_SCRIPT", {
  queryParam: "filter=1,2,34&q"
});
+1

, url .

- :

$("#selector").tokenInput("PATH_TO_SCRIPT&filter=1,2,3", {
  queryParam: "q"
});

+1

, , .

Looking at the source, the url parameter can be a function that is nullified before sending an ajax request. So you can do:

this.$("#abcTextbox").tokenInput(function(){
    return "/path/to/script.php?filter="+$("#myFieldId").val()
}, {
    queryParam: "q"
 ...
});
+1
source

All Articles