I have $('input').on('itemAdded', function (event)
event from bootstrap tagsInput.js library. I am listening on event to add an item to array but the problem is that “self.update()” is called twice adding duplicate items to array.
if I put the event outside mount/update, then it is not fired at all.
I have my code like this:
self.on(“update”, function() {
$('input').on('itemAdded', function (event) {
console.log("ITEM ADDED"); // called twice here
self.parent.data.ivrList[event.currentTarget.id].agentList.push(self.data.MapAgents[event.item]);
});
According to API, it say “In the function this refers to the current tag instance. After the handler is called this.update() is automatically called reflecting all the possible changes to the UI”. I am not sure if this statement refers to my problem above.
How do I fix this?