Permalink
Browse files

fixes #244 -- allow View#events to be defined as a function, making i…

…t easier to call super.
  • Loading branch information...
1 parent 10e71e3 commit 6bb43c1b81c3890548baa23dfefbc7859105e698 @jashkenas committed Aug 3, 2011
Showing with 3 additions and 2 deletions.
  1. +1 −0 backbone.js
  2. +2 −2 test/view.js
View
@@ -949,6 +949,7 @@
// not `change`, `submit`, and `reset` in Internet Explorer.
delegateEvents : function(events) {
if (!(events || (events = this.events))) return;
+ if (_.isFunction(events)) events = events.call(this);
$(this.el).unbind('.delegateEvents' + this.cid);
for (var key in events) {
var method = this[events[key]];
View
@@ -118,8 +118,8 @@ $(document).ready(function() {
var count = 0;
var ViewClass = Backbone.View.extend({
el: $('body'),
- events: {
- "fake$event.namespaced": "run"
+ events: function() {
+ return {"fake$event.namespaced": "run"};
},
run: function() {
count++;

0 comments on commit 6bb43c1

Please sign in to comment.