0

Just started using token-input, and i didn't manage to make it work the way I wanted. Let me explain :

I was given a String var in javascript, containing data, like token-input local data:

var str='[{id : 1, name : "ADM" },
{id : 2, name : "JCH" },
{id : 3, name : "CGD" }]';

However, I couldn't give a str as a parameter to tokeninput, like this:

$("#input").tokenInput(str, {preventDuplicates : true});

It gives me what I think is error code 500.

Error probably comes with the quote returned by the str var. Problem is I need to use this var, it's kinda imposed.

Any ideas?

1 Answer 1

1

What you should do is

$("#input").tokenInput(JSON.parse(str), {preventDuplicates : true});
Sign up to request clarification or add additional context in comments.

1 Comment

Exactly what I needed. Thanks a lot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.