Skip to content

Commit

Permalink
executing app initializers with the app object as the context
Browse files Browse the repository at this point in the history
  • Loading branch information
Derick Bailey committed Jan 24, 2012
1 parent 9ac12ed commit 96a0c8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backbone.marionette.js
Expand Up @@ -376,7 +376,7 @@ Backbone.Marionette = (function(Backbone, _, $){
this.trigger("initialize:before", options);
for(var i=0; i<this.initializers.length; i++){
var initializer = this.initializers[i];
initializer(options);
initializer.call(this, options);
}
this.trigger("initialize:after", options);
},
Expand Down
5 changes: 5 additions & 0 deletions spec/javascripts/application.spec.js
Expand Up @@ -11,6 +11,7 @@ describe("marionette application", function(){
var module = {};
module.initializer = function(options){
module.options = options;
module.context = this;
};

spyOn(module, "initializer").andCallThrough();
Expand Down Expand Up @@ -39,6 +40,10 @@ describe("marionette application", function(){
it("should pass the options through to the initializer", function(){
expect(MyModule.options).toEqual(someOptions);
});

it("should run the initializer with the context of the app object", function(){
expect(MyModule.context).toEqual(MyApp);
});
});

describe("when instantiating an app with options specified", function(){
Expand Down

0 comments on commit 96a0c8e

Please sign in to comment.