agent2026 schrieb:
> What's a situation where you want to use .bind then?  (still new at this)
> 
> Adam

Maybe avoiding ambiguity. load() is used to either bind an event or load 
content via XHR.

Also, if you want to attach custom events, you'll have to use bind.

$(elem).bind('triggerTab', function() {
     ...
});

Or, if you dynamically want to decide which event to attach, like I do 
in Thickbox Reloaded:

$$.bind((type == CONFIRM ? 'submit' : 'click'), function() {
     ...
});

In addition until jQuery 1.1 new jQuery users very often expected to 
have submit() for instance trigger a form's default action. Thus it was 
discussed, that these helpers should be removed in favor of bind and 
trigger, also to make jQuery smaller. But then it was fixed the other 
way round in jQuery 1.1.

To me, if you use bind, it's much clearer what you intend to do 
(thinking of co-workers that are new to jQuery), and I'm tending to 
solely use bind nowadays.


-- Klaus






_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to