hay / stapes

the Javascript MVC microframework that does just enough
http://hay.github.io/stapes
MIT License
443 stars 54 forks source link

Create() ignores module events #23

Closed erlenstar closed 12 years ago

erlenstar commented 12 years ago

* Edit * Should've RTM, I see now that .extend() returns the extended object, not the result of .create(). Works as expected if I don't chain the two methods.


Love the minimal approach Stapes takes to MVC, but I'm struggling with events. Seems to me that module.create() should copy event handlers that have been set on the template object. E.G.

module = Stapes.create().extend();
module.on("change:name", function() {console.log(this.get('name'));});
module.set("name", "foo");    // console reads "foo"

new_module = module.create();
new_module.set("name", "bar");  // to my mind, this should trigger the "change:name" event set above

Without a proper constructor, it's a bit onerous to add the events manually after an object is generated using .create()