I'm currently converting lots of code that uses prototype.js to
MochiKit usage for obvious reaons :-)

I use MochiKit.DOM.addToCallStack() instead of prototype's
Event.observe() to connect event handlers. In some places I used
prototype's Event.stopObserving() to remove an event handler, so I
wrote this short function as a replacement:

bbot.removeFromCallStack = function(target, path, func) {
  var existing = target[path];
  if (typeof(existing) == 'function'
      && typeof(existing.callStack) == "object"
      && existing.callStack != null)
    existing.callStack = filter(existing.callStack, function(f) {return
f != func;});
};

This only works if the event handler has been registered with
addToCallStack(), of course.

Do you think this implementation is ok or do you see any flaws? If it
is ok, how about adding it (or something like it) to MochiKit.DOM?

I know there has been discussion about event handlers in this group,
but this stuff could be useful for other things than events/event
handlers.

-jojo

Reply via email to