Open jinglescode opened 4 years ago
Would also like to know how to use this component in react
I guess it is because the input value was set by javascript by the bulma-tagsinpput and value set by javascript won't trigger onChange event.
My workaround is setting up the 'after.add' and 'after.remove' event and then trigger the handleChange(). The following is what i did for my input component.
...
const attachTagsInput = () => {
const tagInput = document.getElementById('<INPUT_ID>');
const bti = new BulmaTagsInput(tagInput);
bti.on('after.add', function(data) {
handleChange();
});
bti.on('after.remove', function(data) {
handleChange();
});
};
useEffect(() => {
window.addEventListener('DOMContentLoaded', attachTagsInput);
return () => {
window.removeEventListener('beforeunload', attachTagsInput);
};
}, []);
...
I am using this as a standalone TagInput component, where whenever I want to use it, I will import it and use it like:
Unfortunately, @creativebulma/bulma-tagsinput doesn't detect onChange, as such, I can't retrieve the values that are within the TagInput. What am I missing here?
This code is taken and modified from original codepen provided by creativebulma: