In another thread I wrote:

> The biggest problem with events at the moment is only Elements can fire
> them. This makes MVC difficult because the Model (javascript objects) not
> the view (HTML elements) would ideally fire the events.
> For Prototype2, maybe there should be an observable mixin. When mixed in,
> any object can fire events.

To which Toby replied:

> This is already possible with our current event system using the
> `document` object as broker.
> Please see a basic, untested implementation here:

The implementation linked here is good, but isn't there a problem with:

//Foo mixes in Observable
var a = new Foo();
var b = new Foo();

a.observe( 'change', function(){alert( 'a changed' )};
b.observe( 'change', function(){alert( 'b changed' )};'change');

// both listeners are now notified even though only object a fired.

One fix might be to do:

line22: this.somethingUnique + eventName, data);

line 26:
document.observe( this.somethingUnique + eventName, callback);

But I don't know where the somethingUnique would come from.


my wiki ajaxification thing:
my blog:

You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to