dragonofmercy / Tokenize2

Tokenize2 is a plugin which allows your users to select multiple items from a predefined list or ajax, using autocompletion as they type to find each item. You may have seen a similar type of text entry when filling in the recipients field sending messages on facebook or tags on tumblr.
https://dragonofmercy.github.io/Tokenize2/
BSD 3-Clause "New" or "Revised" License
83 stars 25 forks source link

How to pass selected option in JSON data? #57

Closed sunnykasera3107 closed 5 years ago

sunnykasera3107 commented 5 years ago

Hi there,

I am using the tokenize2 plugin for multiselection and autocomplete. And it is a perfect plugin. But I am facing an issue with that, I don't know how to pass selected option attribute with JSON data source. So that when user load page he may see some options already selected.

Just FYI, I am using data source as URL, not select type.

Many thanks in advance. Sunny

dragonofmercy commented 5 years ago

Hi the data source is only used when searching value, if you have to display selected option on load, just put "selected" attribute to options.

Have a look to this issue https://github.com/zellerda/Tokenize2/issues/9

sunnykasera3107 commented 5 years ago

But I do not have option. I am using Json for data source.

On Thu, 4 Oct 2018, 1:05 pm David Zeller, notifications@github.com wrote:

Hi the data source is only used when searching value, if you have to display selected option on load, just put "selected" attribute to options.

Have a look to this issue #9 https://github.com/zellerda/Tokenize2/issues/9

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zellerda/Tokenize2/issues/57#issuecomment-426915466, or mute the thread https://github.com/notifications/unsubscribe-auth/AH4kJHbznjRVn64MJiWxGIXW6yI_t6mSks5uhbpBgaJpZM4XFs4u .

dragonofmercy commented 5 years ago

You have to fetch your json on load manually and for each item, use this method

$('.tokenize-demo').tokenize2().trigger('tokenize:tokens:add', ['token value', 'token display text', true]);
sunnykasera3107 commented 5 years ago

Hi David,

Okay, that seems good. But I am facing one more issue there. The issue is on mobile devices. When the user clicks on the drop-down. And wanted to not select any category and want to close the dropdown so he cannot close it. Until he select any category, he cannot close that dropdown.

On Thu, Oct 4, 2018 at 2:08 PM David Zeller notifications@github.com wrote:

You have to fetch your json on load manually and for each item, use this method

$('.tokenize-demo').tokenize2().trigger('tokenize:tokens:add', ['token value', 'token display text', true]);

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zellerda/Tokenize2/issues/57#issuecomment-426933498, or mute the thread https://github.com/notifications/unsubscribe-auth/AH4kJN1Uct8UQkkWaDc-E3NckqQSYd6Zks5uhcj7gaJpZM4XFs4u .