Created
January 26, 2012 03:36
-
-
Save mxriverlynn/1680805 to your computer and use it in GitHub Desktop.
security and modularity in js apps
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
| @{var user = (CustomPrincipal)User;} | |
| @if (user.Can("locations/manage")) | |
| { | |
| @Html.LocationManagementScripts() | |
| } | |
| @if (user.Can("locations/search")) | |
| { | |
| @Html.LocationSearchScripts() | |
| } |
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
| myApp = new Backbone.Marionette.Application(); | |
| myApp.addInitializer(function(options){ | |
| var myView = new MyView({ | |
| model: options.someModel | |
| }); | |
| MyApp.mainRegion.show(myView); | |
| }); | |
| myApp.addInitializer(function(options){ | |
| new MyRouter(); | |
| new SomeOtherView().render(); | |
| }); | |
| myApp.start(); |
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
| // -------------------- | |
| // app.js | |
| myApp = new Backbone.Marionette.Application(); | |
| myApp.addRegions({ | |
| mainRegion: "#main" | |
| }); | |
| // -------------------- | |
| // locationSearch.js | |
| (function(myApp, Backbone){ | |
| var SearchView = Backbone.View.extend({ | |
| // ... | |
| }); | |
| myApp.addRegions({ | |
| searchRegion: "#search" | |
| }); | |
| myApp.addInitializer(function(){ | |
| var view = new SearchView(); | |
| view.render(); | |
| myApp.searchRegion.show(view); | |
| }); | |
| })(myApp, Backbone); | |
| // -------------------- | |
| // index.html | |
| <script language="javascript"> | |
| myApp.start(); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment