Last active
August 29, 2015 14:12
-
-
Save urosgruber/84a70c7980ec13f2dfbc to your computer and use it in GitHub Desktop.
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.addRegions({ | |
| mainRegion: "#content" | |
| }); | |
| // Models | |
| ShutterModel = Backbone.Model.extend({ | |
| urlRoot: "/api/shutters", | |
| idAttribute: "_id" | |
| }); | |
| ShutterCollection = Backbone.Collection.extend({ | |
| model: ShutterModel, | |
| url: "/api/shutters" | |
| }); | |
| // Views | |
| ShutterView = Backbone.Marionette.ItemView.extend({ | |
| template: "#shutter-template", | |
| tagName: "tr", | |
| //className: "shutter", | |
| events: { | |
| 'click .up img': 'shutterUp', | |
| 'click .down img': 'shutterDown' | |
| }, | |
| shutterUp: function(){ | |
| console.log("Shutter Up"); | |
| }, | |
| shutterDown: function(){ | |
| console.log("Shutter Down"); | |
| } | |
| }); | |
| ShuttersView = Backbone.Marionette.CompositeView.extend({ | |
| //id: "shutters", | |
| template: "#shutters-template", | |
| childView: ShutterView, | |
| childViewContainer: ".collection-container" | |
| }); | |
| // Startup | |
| MyApp.addInitializer(function(options){ | |
| var shutters = new ShutterCollection(); | |
| shutters.fetch(); | |
| var shuttersView = new ShuttersView({ | |
| //model : ShutterModel, | |
| collection : sutters | |
| }); | |
| MyApp.mainRegion.show(shuttersView); | |
| }); | |
| $(document).ready(function(){ | |
| 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Remote Shutter Control</title> | |
| <script src="./lib/jquery-2.1.3.js"></script> | |
| <script src="./lib/underscore.js"></script> | |
| <script src="./lib/backbone.js"></script> | |
| <script src="./lib/backbone.wreqr.js"></script> | |
| <script src="./lib/backbone.babysitter.js"></script> | |
| <script src="./lib/backbone.marionette.js"></script> | |
| <link href="./css/bootstrap.css" rel="stylesheet"> | |
| <script src="./js/application.js"></script> | |
| </head> | |
| <body> | |
| <div id="content"> | |
| </div> | |
| <script type="text/template" id="shutters-template"> | |
| <table class="table-striped table-bordered"> | |
| <!-- want to insert collection children, here --> | |
| <tbody class="collection-container"></tbody> | |
| </table> | |
| </script> | |
| <script type="text/template" id="shutter-template"> | |
| <td><img class='shutter_pic' src='<%= image_path %>' /></td> | |
| <td><%= name %></td> | |
| <td> | |
| <div class='up'><img src='public/images/up.gif' /></div> | |
| <div class='down'><img src='public/images/down.gif' /></div> | |
| </td> | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment