Populate JQuery TokenInput on AJAX event
Asked Answered
C

1

-2

Let say a jQuery TokenInput is attached with a text field with a pre populate parameter defined during its initialization.

Now I want to populate that input field with some tokens on an event trigger without re-initialization of this plugin.

Crayon answered 11/3, 2014 at 13:43 Comment(0)
C
2

I have found the solution of my work. Thats why I am posting here so that others can benefit from this answer.

Let say Occupation is my field with id "occupation".

$("#occupation").tokenInput("add", {id: 1, name: "Software Engineer"});

"add" is a function which adds the json record as a token on the fly.

Hope it helps.

Thanks

Crayon answered 11/3, 2014 at 13:47 Comment(1)
@JohnMax, "add" is the built-in function provided by tokeninput. You just need to apply tokenInput on text field and if you want to populate a field with some token then provide json in the second parameter. For example, In my case I am prepopulating only one tag. Vote Up :)Crayon

© 2022 - 2024 — McMap. All rights reserved.