Hacker Newsnew | comments | show | ask | jobs | submitlogin

This is probably a little bit late for this release, but have you ever considered allowing arrays or strings with spaces on the value side of the events hash? This would allow you to define different functions to call in order when an event is fired, instead of just a single function that has to call them itself. I've run into a few situations where this would be useful, and seems like a very small change. Should I send a pull request?



Ha ha. That's actually already in 0.9.0, and I managed to miss it when reading through the commit list for the change log.

I've added the corresponding documentation, and added it to the change log for 0.9 as well.

http://backbonejs.org/#Events-on

-----


I'm not familiar with the Backbone code or config. However, it sounds like you are setting an argument by specifying a function name in a string. If you want to specify multiple functions, then instead of specifying them in a string I'd say Backbone should accept either a string or a function as the argument value. That would let you define your event handler in-place, and you could define one that just calls a series of other functions.

-----


No, that's not quite it. It's simply that you're now allowed to bind and trigger multiple event names in a single call, as in jQuery. For example:

    book.on("change:title change:author", function() {
      ...
    });

-----




Applications are open for YC Summer 2015

Guidelines | FAQ | Support | Lists | Bookmarklet | DMCA | Y Combinator | Apply | Contact

Search: