Don't use "." custom jQuery events [5.2.1-RC1]
Right now we're using "." in custom jQuery events to add them to namespaces. For example In-Portal thinks, that "FormManager.WindowManager.Ready" event has following parts:
- "Ready" - event name
- "FormManager.WindowManager" - event namespace
Unfortunately for us the jQuery, according to http://api.jquery.com/on/ page (see "Event names and namespaces" section), interprets "FormManager.WindowManager.Ready" event like this:
- "FormManager" - event name
- "WindowManager" and "Ready" - event namespaces
As a result the the following events were considered equal:
- FormManager.WindowManager.Ready
- FormManager.WindowManager
- FormManager.Ready
To solve that problem we need to use anything other, then dot (".") to separate out internal event namespace, e.g. "\" (as in PHP) or ":" (as in http://lostechies.com/derickbailey/2011/09/15/zombies-run-managing-page-transitions-in-backbone-apps/) or maybe even "/".
Our Namespace Separator | jQuery Namespace | Event Name |
---|---|---|
/ | jQueryNamespace | FormManager/WindowManager/Ready.jQueryNamespace |
\\ | jQueryNamespace | FormManager\\WindowManager\\Ready.jQueryNamespace |
: | jQueryNamespace | FormManager:WindowManager:Ready.jQueryNamespace |
The actual ".namespace" syntax need to be used by code, that listens to that event for easy event listener distinction later on (if we need to remove all in single namespace).
For example string "FormManager\WindowManager\Ready.Uploader" indicates, that it's event listener, that:
- listens for "FormManager\WindowManager\Ready" event
- is related to Uploader
This way locating event listener created from Uploader would be a breeze.