Event "Namespaces"

Event "Namespaces"

<div id="mb_0">
<div>What's the best way to unbind anonymous functions? For example to remove a function later on I'd have to:</div>
<div> </div>
<div>var foo = function() { ... };</div>
<div> </div>
<div>$(...).bind('event', foo);</div>
<div>// More code</div>
<div>$(...).unbind('event', foo);</div>
<div> </div>
<div>I see that there's a guid that jQuery assigns to the function passed in which it uses in the event.remove method. What are people's thoughts about assigning a "class" or namespace to an event to ease unbinding for your plugin/code?
</div>
<div> </div>
<div>For example:</div>
<div> </div>
<div>$(...).bind('event.myPlugin', function() {});</div>
<div> </div>
<div>// This would unbind all events of type 'event' that have a 'myPlugin' class assigned.</div>
<div>$(...).unbind('event.myPlugin');</div>
<div> </div>
<div>Would anyone else find this useful? I'm sure it'd make a nice plugin :D</div><span class="sg">
<div> </div>
<div>-js</div></span></div>