BhaskerYadav BhaskerYadav - 6 months ago 15
Javascript Question

Event listener when tag is removed from auto complete jquery

I am using auto complete component of jquery. I have a select listener when a data is selected ,

$( ".aops-autocomplete" ).on('autocompleteselect', function (e, ui) {
selectedTags.push(this.value);
});


As we can see on select of an element I am adding that to an array.

Now, I want to remove this when user deletes a tag from auto complete.
I don't know what listener should I use for this event.

I have tried remove, removeData but had no luck.

Answer

I found a solution by myself,

$(document).on("click", ".ui-icon", function(){
    var removedTag=$(this).parent().text();
    alert("Tag removed : "+removedTag);
});

I used delegated listener on its child component.