Is it good practice to create and dispatch custom Javascript events?

My web application uses document.createEvent and event.initEvent to create custom events of the generic type Event .

I wonder if this is considered good practice. On the other hand, I can use the DOM event system that already exists, and I do not need to invent and implement my own; on the other hand, this can lead to name conflicts if future standardized event models determine the type of event with the name that I have chosen. (Or is this possible for event type names?)

I ask because I just found out by looking at stackoverflow that sets custom properties for DOM objects or inline Javascript objects is considered bad practice.

EDIT I think I found something: http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-CustomEvent

So let me rephrase my question: Do I understand the cited section correctly in that it is recommended to use CustomEvent inside a web application?

ADDITIONAL WARNING I just noticed that CustomEvent not supported in versions of Firefox prior to 6. It is supported in current Webkit-based browsers.

+7
source share
1 answer

If you are going to create something and make it as a namespace proof as you can, you can do what Webkit and Mozilla do, and add a nickname to the beginning of all the names of your events. How:

 _marc_trap_door_shut _marc_trap_door_open _marc_trap_door_ajar ... etc ... 
+3
source

All Articles