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
Binders.SpotsNewRoute = Binders.ModalEditRoute.extend | |
model: (params) -> | |
m = Binders.Spot.createRecord() | |
m.setProperties | |
account_service: Binders.AccountService.createRecord() | |
agency_production: Binders.AgencyProduction.createRecord() | |
creative: Binders.Creative.createRecord() | |
digital: Binders.Digital.createRecord() | |
planner: Binders.Planner.createRecord() |
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
#The code before the update. Used to work, but now it breaks. | |
Binders.SpotsEditRoute = Em.Route.extend | |
model: () -> | |
Binders.Spot.find 1234 | |
Binders.Router.map -> | |
@resource 'spots', -> | |
@route 'new' | |
@route 'edit', { path: ':spot_id/edit' } |
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
DS.RESTAdapter.map('App.Database', { | |
primaryKey: 'name' | |
collections: { embedded: 'load' } | |
}); | |
DS.RESTAdapter.map('App.Collection', { | |
primaryKey: 'name' | |
}); |
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
#Must be defined before you create the application. | |
DS.RESTAdapter.registerTransform 'array', | |
deserialize: (value) -> if Ember.isArray value then Em.A(value) else Em.A() | |
serialize : (value) -> if Ember.isArray value then Em.A(value) else Em.A() |
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
{ [ { id: "32111aae", spot_number: "BAH", commercials: [{ id: "33321eaz", title: "yar"}] } ] } | |
Binder.Spot = DS.Model.extend({ | |
spot_number: DS.attr('string') | |
}); | |
Binder.Commercial = DS.Model.extend({ | |
title: DS.attr('string'), | |
spot: DS.belongsTo(Binder.Spot) | |
}); |
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
this.set('content.name', 'test'); | |
Content isDirty is set to true and css class is added. | |
record = App.Model.createRecord(); | |
this.set('content', record); | |
Content isDirty is set to true and css class is not added. | |
{{view.content.isDirty}} | |
<div class="label label-important" {{bindAttr class="view.content.isDirty:unsaved"}}>unsaved changes</div> |
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
#= require_tree . | |
window.App = App = Ember.Application.create() | |
App.Models = {} | |
App.Views = {} | |
# Models | |
DS.Adapter.configure 'plurals', | |
sticky: 'stickies' |
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
EmberTodo.ItemController = Ember.ObjectController.extend({ | |
completed: function(key, value) { | |
if (arguments.length > 1){ | |
var item = this.get("content"); | |
console.log("initial value"); | |
console.log(item.get("completed")); | |
item.set("completed", value); | |
console.log("after value"); | |
console.log(item.get("completed")); | |
console.log("is dirty?"); |
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> | |
<meta charset="utf-8"> | |
<script src="scripts/vendor/jquery.min.js"></script> | |
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet" type="text/css" /> | |
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet" type="text/css" /> | |
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap.js"></script> | |
<title>Skillshare</title> | |
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
#Model | |
Diets.FoodNutrient = DS.Model.extend | |
amount: DS.attr 'string' | |
name: DS.attr 'string' | |
nutrient_id: DS.attr 'string' | |
Diets.Food = DS.Model.extend | |
brand: DS.attr 'string' | |
food_nutrients: DS.hasMany( Diets.FoodNutrient ) |