yairEO / tagify

🔖 lightweight, efficient Tags input component in Vanilla JS / React / Angular / Vue

Home Page:https://yaireo.github.io/tagify/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Writing to tagify textarea

lee-matthews opened this issue · comments

Hi,

I can save the the contents of my tagify text area using :

document.getElementById(ElementId).value;

However, I'd also like to be able to write the previously saved data to the tagify textarea. I've tried setting document.getElementById(ElementId).value but this doesn't work.

Could you please explain how to do this?

Thanks again
Lee

Can you make a demo page showing what you're trying to do?
Use this is a template: https://jsbin.com/degobup/edit?html,js,output

Is this related this this ticket?

#292

Thanks for getting back to me @yairEO

This request was more about reading and writing to a tagified text area more than using a database.

Thanks to a comment from Dinosaur Burger, I managed to write data back to the tagify textarea using - var commentHtml= tagify.parseMixTags(replyVal); //turns tags back into html.

You can find my modifications here
https://jsbin.com/dofejejuha/edit?html,js,output

What I notice however is that if the same tag is repeated, when it is written back into the textarea, the second second isn't displayed properly - it shows something like this instead : {"value":"lee","title":"lee"}

How can I get parseMixTags to work properly when duplicate tags are used?

Thanks again.

@lee-matthews you need to parse the value first (using JSON.parse):

commentHtml= tagify.parseMixTags(  JSON.parse(databaseField.value)  )