So this (with specialized lib, and fairly large unintuitive js code to set whole thing up):<p><pre><code> <div id="foo" jsaction="leftNav.clickAction;
dblclick:leftNav.doubleClickAction">
</code></pre>
is pretty much the same as this:<p><pre><code> <div id="foo"
onclick="Actions.leftNav.clickAction()"
ondblclick="Actions.leftNav.doubleClickAction()">
</code></pre>
without any abusing or manipulating of html and dom and with setup as simple and understandable as this:<p><pre><code> window.Actions = {
leftNav: {
clickAction: function() {
myApp.LeftNav.doSomeSeriousStuff();
},
doubleClickAction: function() {
// very late loading of implementation
require("LeftNavActions", function(LeftNavActions) {
LeftNavActions.doSomeOtherSeriousStuff();
})
},
// if you want add handlers from other places
// with Actions.leftNav._anotherAction.push()
_anotherAction: [],
anotherAction: function() {
this._anotherAction.forEach(function(a) { a(); });
}
}
}
</code></pre>
Actions is a good idea that I remember from Delphi 4. It is just one additional layer of indirection that enables you to attach same behavior for example to menu option and toolbar button.