Skip to content

Commit

Permalink
fix controller data property assignment in ctor...
Browse files Browse the repository at this point in the history
This allows the data function not to be defined. But if it is defined,
and it's a function, bind it to the controller instance.

fixes #962 while still also fixing #929. @tmeasday, confirm.
  • Loading branch information
cmather committed Oct 27, 2014
1 parent 92aa92d commit 960dc77
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/route_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ RouteController = Controller.extend({
// is defined anywhere in the chain. This ensure that if we have
// a data function somewhere in the chain, you can call this.data().
this.data = this.lookupOption('data');
// all setting data statically, e.g. data: {foo: 'bar'}
if (typeof this.data !== 'function') {
var data = this.data;
this.data = function() { return data; }
}
if (this.data)

if (typeof this.data === 'function')
this.data = _.bind(this.data, this);

this.init(options);
Expand Down

0 comments on commit 960dc77

Please sign in to comment.