Last active
August 29, 2015 13:57
-
-
Save a-axton/9402641 to your computer and use it in GitHub Desktop.
Creating a marionette module that can be placed within other areas of the application via Foo.display
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Application.js file | |
| var MyApp = new Backbone.Marionette.Application(); | |
| MyApp.addRegions({ | |
| someRegion: "#some-div" | |
| }); | |
| MyApp.addInitializer(function(options){ | |
| if(options.somethingOrOther) { | |
| MyApp.Foo.display(MyApp.someRegion); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Foo module.js files | |
| MyApp.module("Foo", function(Foo, App){ | |
| Foo.addInitializer(function(){ | |
| // Do things once the module has started | |
| }); | |
| // layout can be subbed as different view type | |
| var layout = Backbone.Marionette.Layout.extend({ | |
| }); | |
| // function to display module inside of another | |
| Foo.display = function (region) { | |
| region.show(new layout()); | |
| }; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment