Skip to content

Instantly share code, notes, and snippets.

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()
@cloke
cloke / gist:5666885
Last active December 17, 2015 20:19
#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' }
@cloke
cloke / response
Last active December 14, 2015 02:39 — forked from fredjiles/response
DS.RESTAdapter.map('App.Database', {
primaryKey: 'name'
collections: { embedded: 'load' }
});
DS.RESTAdapter.map('App.Collection', {
primaryKey: 'name'
});
#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()
{ [ { 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)
});
@cloke
cloke / gist:4637506
Last active December 11, 2015 17:49
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>
#= require_tree .
window.App = App = Ember.Application.create()
App.Models = {}
App.Views = {}
# Models
DS.Adapter.configure 'plurals',
sticky: 'stickies'
@cloke
cloke / gist:4616769
Last active December 11, 2015 14:49 — forked from earnold/gist:4616732
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?");
@cloke
cloke / html.html
Last active December 11, 2015 14:28 — forked from mklew/html.html
<!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>
#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 )