>> var counter = 0;
>> $().click(function(event) { if(counter++ == 5) $(this).unbind(event);
>> ... });
>> That was pretty hard to do before.
 
I think that example only makes sense if a single element is selected. With
multiple elements selected, it will unbind one element's event handler on
the 5th click to any element in the group, but leave handlers bound to the
others no matter how many more times they were clicked. Changing == to >=
doesn't help because it's still a collective click count for all selected
elements.

To get the behavior I think you were trying to get--allow exactly five
clicks on each selected element--it seems like the count would have to be
stored in an expando property on each element.

> I'm wondering: Would arguments.callee be a better place to attach the
counter variable to?

The callee of the anonymous click function is jQuery.event.trigger(), I
don't think you'd want to attach it to that. 


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to