-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.

Chris
  • 5,882
  • 2
  • 32
  • 57
Ata ul Mustafa
  • 1,172
  • 12
  • 18

1 Answers1

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

Ata ul Mustafa
  • 1,172
  • 12
  • 18
  • @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 :) – Ata ul Mustafa Nov 04 '16 at 10:58