JQuery, what event to handle when adding / removing token input?

I am using tokeninput for an autocomplete text box.

Now I want to show the hidden div base on the token input.

so in what event could I get input token values ​​at the time of adding / removing?

+3
source share
3 answers

If you use http://loopj.com/jquery-tokeninput/ , then they have add removecallbacks registered on their homepage

onAdd
A function to call whenever the user adds another token to their selections. defaut: null (demo).
onDelete
A function to call whenever the user removes a token from their selections. default: null (demo).

Syntax

    $("#selector").tokenInput("fetch.php", {
         onAdd: function (item) {
             alert("Added " + item.name);
         },
         onDelete: function (item) {
            alert("Deleted " + item.name);
        }
   });

See a demo here search onAdd onDelete http://loopj.com/jquery-tokeninput/demo.html#onadd-ondelete

+6
source

, onAdd, , .

:

  • onResult

    , . , . default: null ().

  • onAdd

    , . defaut: null (demo).

  • OnDelete

    , . default: null (demo).

  • onReady

    tokeninput . default: null

+3

, :

var addFunction = function (item) {
    .... 
};

var deleteFunction = function (item) {
    ....
};

this.$("#mySelector").tokenInput("/ABC/GetMethod", {
    preventDuplicates: true,
    theme: "facebook",    
    queryParam: "term",
    tokenLimit: 1,
    onAdd: addFunction,
    onDelete: deleteFunction
});
0

All Articles