3

I would like to understand how jQuery event namespacing works across different browsers.

I don't see anything about this on MDN and I would like to know how to namespace events without using jQuery as well (on older IE as well on modern browsers)


Update (Oct 1st, 2017):

If anyone is interested, I've answered in another question how to write minimal events emitter with namespaces in Vanilla JavaScript: https://stackoverflow.com/a/44432013/104380

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
vsync
  • 118,978
  • 58
  • 307
  • 400
  • jQuery [trigger](https://github.com/jquery/jquery/blob/master/src/event/trigger.js) source code – vsync Dec 22 '19 at 11:45

1 Answers1

3

jQuery event namespaces are exactly that – jQuery event namespaces.

This feature is unique to jQuery; the DOM doesn't have anything like it.

The point of event namespaces is the ability to remove your event handlers by name only; the DOM APIs don't do that at all.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • I know what they are and what they do, i want to know how they work so I could write my own code which does the same, without jQuery (so events won't collide) – vsync Feb 26 '13 at 17:49
  • 4
    @vsync: Read the jQuery source. You can maintain an object of event handlers for each namespace and loop over them when raising events. – SLaks Feb 26 '13 at 18:06