.unbind example question

1 view
Skip to first unread message

Andrey Fedorov

unread,
Aug 31, 2007, 7:22:39 PM8/31/07
to jquer...@googlegroups.com
Hi all,

I'm a bit hesitant about this example in the old documentation of .unbind:

 $("p").unbind( "click", function () { alert("Hello"); } )

Would using an anonymous function really work here?

- Andrey

John Resig

unread,
Aug 31, 2007, 7:51:34 PM8/31/07
to jquer...@googlegroups.com
Nope! Good catch. The example should definitely be expanded, then.

function foo(){ ... }
.bind("click", foo);
.unbind("click", foo);

--John

Andrey Fedorov

unread,
Aug 31, 2007, 8:10:28 PM8/31/07
to jquer...@googlegroups.com
Done. Also, aren't .blur(), .click(), .focus(), etc. redundant in light of .trigger("blur"), .trigger("click"), .trigger("focus"), etc.?

- Andrey

John Resig

unread,
Aug 31, 2007, 8:11:48 PM8/31/07
to jquer...@googlegroups.com
Sure - and so are .click(fn) when compared to .bind("click", fn). It's
just a convenience (and a trivial amount of code to keep it in).
Reply all
Reply to author
Forward
0 new messages