Ilja
Ilja

Reputation: 46479

issues with .off("DOMSubtreeModified")

I have a logic like this:

$('.myElement').on('DOMSubtreeModified', function() {
   if(something == true) {
      $('.myElement').off('DOMSubtreeModified');

      // Execute some code
   }
});

Will the // Execute some code be executed after I remove DOMSubtreeModified listener? I do this to ensure that same code is not executed if certain condition is met, hence need to stop listening to DOM changes.

Upvotes: 2

Views: 717

Answers (1)

Vivek
Vivek

Reputation: 4886

Try this:

$('.myElement').off('DOMSubtreeModified', arguments.callee);

Upvotes: 5

Related Questions