Is it possible to associate a function with another function when called? For example, it would look something like this:
function a(){...} function b(){...} b.bind("onInvoke","a");
Therefore, when b is called, a is automatically called.
EDIT: OK OK, to clarify, this is not a chain issue. The idea is to find an elegant way to bind an event. Follow the normal "non-forest" method with calling a regular function callback:
function handler(){...} function caller1(){handler(); ...} function caller2(){handler(); ...} function caller2(){handler(); ...}
Does this work correctly? But what if I have a call all over the place? Itβs hard to organize or change things.
Now look for an excellent solution! (If one exists)
function handler(){...} // Caller make no reference to handler on creation function caller1(){...} function caller2(){...} function caller3(){...} // Caller function are still all over the place, all over your website // Event handler registered later in one location here, doesn't matter where they are phsically caller1.bind("onInvoke",handler); caller2.bind("onInvoke",handler); caller3.bind("onInvoke",handler);
Just like your usual event logging in HTML format is jQuery. You do not write onClick on every image that the user can click (which is everywhere), it would be too difficult to organize this! You just write one simple
$("img").bind("onClick",click_handler);
for the whole site. This is the craziness of what I'm looking for except for the JS features.
I hope this clarifies the situation.
EDIT 2: need to work with IE7 !!! JavaScript 1.8.5 is great, that's all, but nothing supports it right now.