uzairfarooq / arrive

Watch for DOM elements creation and removal
MIT License
869 stars 99 forks source link

Watching for multiple elements #62

Closed manuelmeurer closed 7 years ago

manuelmeurer commented 7 years ago

It seems like when making two calls to arrive, the latter overwrites the former.

$(document).arrive("#foo", function() {});
$(document).arrive("#bar", function() {}); // this overwrites the first

Even when using document on one and window on the other, the first one is overwritten. Is this expected behavior? Can I watch for two separate elements somehow?

uzairfarooq commented 7 years ago

It should work. Here's a jsfiddle https://jsfiddle.net/yd6Lu6w6/5/. Might be some issue your code?

manuelmeurer commented 7 years ago

Thanks! Ist must be an issue with my code then... I solved it another way for now: both elements I'm waiting for are textareas, so I just use one arrive call now waiting for any textarea, and then check whether it's one of the two I'm interested in. 😄