One day I had a very interesting problem. I created a plugin with a scroll event that I had to add/remove, but I realized I can add the event but then how do I remove just my event? .. a .unbind(‘scroll’) call would remove all scroll events, not only the event added by me.

So after a little digging I found “Namespaced events” support in jQuery. What does this mean?…Well one can add a event within a specific namespace and then remove that events from that namespace.

Here is a example, in which I will add a scoll event then remove my scoll event:

  1. //add event
  2. $(window).bind('scroll.customNamespace',function() {});
  4. //remove event
  5. $(window).unbind('scroll.customNamespace');

Then event namespacing is very usefull in any plugin development and is a good to know functionality for day to day development.