I would like to know the event name for a selectbox/drop down when new element get added. This will help me to take a next action.
We have a dropdown which have 10 fixed element, there is a child window. User when click on particular link that item get added in the parent window drop down.
Now, we want to fire an event on addition of new element in drop down, please let me know the approach/event
I think you basically have two options: either you can dispatch an event every time you’re adding a new item to the select element, or you can use a mutation observer to watch the select element for changes of its child nodes:
You’re thinking about this backwards, you don’t want to try and detect when your code modifies the select, you just want to call some other function in the event listener you already have.
myMagicLink.addEventListener('click', function(event) {
// Add <option> to select
// call some other function
})
Edit: Oops, sorry I missed the important part of the question that you’re modifying a parent document. You may want to look at postMessage in addition to the events mentioned above.
MutationObserver is deprecated so will likely go away.