views:

31

answers:

1

I ran into a usage of jQuery's die that is either a custom extension or not documented... According to the jQuery docs, the second parameter should be a method (http://api.jquery.com/die/). I'm seeing a usage where the second parameter is selector string. Does anyone know what this does?

    $("*").die('click', '.optionsMenu');

I'd think its only removing certain click handlers, but not sure precisely what its doing.

+3  A: 

It's not using the parameter (since it's not a function), it's the same as calling:

$("*").die('click');

So it's killing all .live('click',....) events, I think what they meant to do was this:

$('.optionsMenu').die('click');
Nick Craver
It does use the parameter; `$('*').die('click', '.optionsMenu')` is equivalent to `$('.optionsMenu', $('*')).die('click')` which in turn is equivalent to `$('.optionsMenu').die('click')`. Just check lines 979-980.
Tgr
@Tgr - That's just not correct, here's a demo to demonstrate it does *not* work that way: http://jsfiddle.net/nick_craver/mHVXQ/
Nick Craver
D'oh! You are right, of course.
Tgr