function setTagifyEditMode(editable) {
const tagifyElement = document.querySelector("[class^='tagify']");
if (editable) {
tagifyElement.removeAttribute('contenteditable');
tagify.settings.readonly = false;
} else {
tagifyElement.setAttribute('contenteditable', 'false');
tagify.settings.readonly = true;
}
tagify.DOM.input.readOnly = !editable;
// Updating the settings
tagify.update();
}
// Example usage
setTagifyEditMode(false); // Making the Tagify input non-editable
Despite attempting the changes above, the Tagify input remains editable even in non-editable mode. How can I correctly toggle the Tagify input between editable and non-editable states?
Any guidance or suggestions would be greatly appreciated. Thank you!
I know there are examples, but I don't seem to be smart enough to figure out what to do.
I'm working on a JavaScript application where users can create notes with tags. I'm using the Tagify library to enhance the tag input functionality.
I'm initializing the Tagify input as follows:
I need to toggle this Tagify input between:
Here’s my attempt to toggle the editable state:
Despite attempting the changes above, the Tagify input remains editable even in non-editable mode. How can I correctly toggle the Tagify input between editable and non-editable states?
Any guidance or suggestions would be greatly appreciated. Thank you!