This file contains 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
{ food: {_id: 'bc4', brand: 'test', food_nutrients: [{ _id: 'af1', name: 'sodium'}] } | |
FoodNutrient = DS.Model.extend({ | |
name: DS.attr( 'string' ) | |
}); | |
Food = DS.Model.extend( | |
brand: DS.attr( 'string' ), | |
food_nutrients: DS.hasMany( Diets.FoodNutrient ) | |
}); |
This file contains 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.MyCollectionView = Ember.CollectionView.create({ | |
tagName: 'ul' | |
contentBinding: 'some array controller', | |
itemViewClass: Ember.View.extend({ | |
tagName: 'li' | |
template: Ember.Handlebars.compile("the letter: {{view.content}}") | |
}) | |
}); | |
This file contains 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
/** MUTLIPLE STATE MANAGERS **/ | |
activeStateManagers: null, | |
getStateManager: function(stateManager) { | |
return (typeof stateManager === 'string') ? | |
this.get(stateManager+'StateManager') : | |
stateManager; | |
}, |
This file contains 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
News.Router = Core.Router.extend | |
enableLogging: true | |
root: Core.Route.extend | |
index: Core.Route.extend | |
route: '/' | |
redirectsTo: 'nav' | |
nav: Core.Route.extend | |
initialState: 'index' | |
route: '/:nav_id' | |
index: Core.Route.extend |
This file contains 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
<ul> | |
{{#each email in view.content}} | |
{{#email_timecheck email.nice_created_at}} | |
{{/email_timecheck}} | |
Handlebars.registerHelper 'email_timecheck', (conditional, block) -> | |
time = this.get(conditional) | |
if(time != News.masterView.get('email_time')) |
This file contains 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
Assume you are using a bound array named links that is defined like [{link: 'some link', title: 'my nifty link', active: true}, ...] | |
//in JS file. I will assume you have an app called MyApp that was create with Em.Application.create() | |
MyApp.linksController = Em.ArrayProxy.create({ | |
content: [ { link: 'I am a link', title: 'I am a title', active: true } ] | |
}); | |
<!-- Navbar | |
================================================== --> |
This file contains 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
M.HeadingView = Em.View.extend Ember.TextSupport, | |
viewName: 'heading_view' | |
content: null | |
attributeBindings: ['text'] | |
editable: false | |
template: Ember.Handlebars.compile( | |
'{{#if this.editable}} | |
{{view Em.TextField valueBinding="content"}} | |
{{else}} |
This file contains 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
{{view M.Select | |
contentBinding="Desires.elementTypeController" | |
valueBinding="this.type" | |
optionLabelPath="content.label" | |
optionValuePath="content.type" | |
classNames="input-xlarge" | |
}} | |
M.Select = Em.Select.extend({ |
This file contains 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
PostView: Em.View.extend | |
templateName: 'post_container' | |
postBinding: 'App.appController.selection.post' | |
Displays, but does not update until I click on the text field. | |
{{view Em.TextField valueBinding="post.managing"}} | |
Displays and updates | |
{{view Em.TextField valueBinding="parentView.content.post.managing"}} |
This file contains 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
M.Paragraph = Em.View.extend(Ember.TextSupport, { | |
viewName: 'paragraph_view', | |
content: null, | |
attributeBindings: ['text'], | |
text: '', | |
editable: false, | |
_editable: (function() { | |
console.log(arguments); | |
return this.set('editable', Em.getPath(arguments[1])); | |
}).observes('M.editable.status'), |