0

I've attached a delegated event handler this way:

$('#static-div').on('click.myNamespace', '.attach-to-this', someFunction);

How do I then, later, reverse this action and remove all delegated events in that namespace? The static-div element is always on the page and only its contents change.

I tried the following, but neither worked:

$('#static-div').off('myNamespace');
$('#static-div').off('myNamespace', '**');

I feel like this should be easier than it is....

Thanks.

Matt
  • 23,363
  • 39
  • 111
  • 152

1 Answers1

0

You need to include the period when removing events from a namespace.

For example, $('#static-div').off('.myNamespace');

See the docs for more info: http://api.jquery.com/off/

Bryan Downing
  • 15,194
  • 3
  • 39
  • 60