This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| define( | |
| [ 'common/model/baseModel' ], | |
| function (BaseModel) { | |
| return BaseModel.extend({ | |
| urlRoot: function() { | |
| }, | |
| defaults: function() { |
| <select class="quantity"> | |
| <% | |
| for (var i = 1; i <= 5; i++) { | |
| // If current index equals model's quantity, flag item as selected. | |
| var isSelected = (i === data.quantity); | |
| %> | |
| <option <% if (isSelected) { %>selected="true"<% } %>><%= i %></option> | |
| <% | |
| } | |
| %> |
| define( | |
| [ | |
| 'underscore', | |
| 'backbone', | |
| 'common/view/baseView', | |
| // text! indicates that what "this" is referencing is a template | |
| 'text!store/template/cartWidget.html' | |
| ], | |
| function ( _, Backbone, BaseView, tpl) { | |
| return BaseView.extend({ |
| define( | |
| [ | |
| 'underscore', | |
| 'backbone' | |
| ], | |
| function ( _, Backbone) { | |
| return Backbone.Model.extend({ | |
| defaults: function() { | |
| return { | |
| title: null, |
| define( | |
| [ 'common/model/baseModel' ], | |
| function (BaseModel) { | |
| return BaseModel.extend({ | |
| urlRoot: function() { | |
| return '/api/store/' + this.get('storeId') + '/stock'; | |
| }, | |
| defaults: function() { | |
| return { |
| define( | |
| [ | |
| 'common/model/baseModel' | |
| ], | |
| function (BaseModel) { | |
| return BaseModel.extend({ | |
| defaults: function() { | |
| return { | |
| title: null, | |
| price: 0, |
| (function (export) { | |
| var App = export.App = {}; | |
| // Stores state/current views of the App | |
| App.state = {}; | |
| App.state.currentPlayer = null; | |
| // Model containing the player | |
| App.PlayerModel = Backbone.Model.extend({}); | |