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
(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({}); | |
define( | |
[ | |
'common/model/baseModel' | |
], | |
function (BaseModel) { | |
return BaseModel.extend({ | |
defaults: function() { | |
return { | |
title: null, | |
price: 0, |
define( | |
[ 'common/model/baseModel' ], | |
function (BaseModel) { | |
return BaseModel.extend({ | |
urlRoot: function() { | |
return '/api/store/' + this.get('storeId') + '/stock'; | |
}, | |
defaults: function() { | |
return { |
define( | |
[ | |
'underscore', | |
'backbone' | |
], | |
function ( _, Backbone) { | |
return Backbone.Model.extend({ | |
defaults: function() { | |
return { | |
title: null, |
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({ |
<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( | |
[ 'common/model/baseModel' ], | |
function (BaseModel) { | |
return BaseModel.extend({ | |
urlRoot: function() { | |
}, | |
defaults: function() { |
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