Ember Latest
The latest build of Ember.
by Kerrick
HTML
<script src="http://builds.emberjs.com/handlebars-1.0.0.js"></script>
<script src="http://builds.emberjs.com/ember-latest.js"></script>
<script src="http://builds.emberjs.com/tags/v1.0.0-beta.7/ember-data.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.5.3/jquery.mockjax.js"></script>
<script type="text/x-handlebars" data-template-name="application">
<h1>ember-latest jsfiddle</h1>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
<h2>Index Content:</h2>
<button {{action "uninherit"}} {{bind-attr disabled="uninherited"}}>Uninherit</button>
<h3>Properties</h3>
<ul>
<li>ID: {{id}}</li>
<li>String: {{string}}</li>
<li>Number: {{number}}</li>
<li>Boolean: {{boolean}}</li>
<li>
{{#if inherited}}
<b>This model is inherited</b>
{{else}}
<i>This model is not inherited</i>
{{/if}}
</li>
</ul>
<h3>Flags</h3>
<ul>
<li>isLoaded: {{isLoaded}}</li>
<li>isDirty: {{isDirty}}</li>
<li>isSaving: {{isSaving}}</li>
<li>isDeleted: {{isDeleted}}</li>
<li>isError: {{isError}}</li>
<li>isNew: {{isNew}}</li>
<li>isValid: {{isValid}}</li>
</ul>
</script>
JavaScript
App = Ember.Application.create({});
App.IndexRoute = Ember.Route.extend({
model: function(){
return this.get('store').find('foo', 1);
},
actions: {
uninherit: function() {
var oldFoo, newFoo;
oldFoo = this.modelFor('index');
newFoo = this.get('store').createRecord('foo', {
string: oldFoo.get('string'),
number: oldFoo.get('number'),
boolean: oldFoo.get('boolean'),
inherited: false,
});
this.controllerFor('index').set('model', newFoo);
this.set('currentModel', newFoo);
},
}
});
App.Foo = DS.Model.extend({
string: DS.attr('string'),
number: DS.attr('number'),
boolean: DS.attr('boolean'),
inherited: DS.attr('boolean'),
uninherited: Ember.computed.not('inherited')
});
App.ApplicationAdapter = DS.RESTAdapter.extend();
$.mockjax({
url: '/foos/1',
responseText: {
foos: [
{
id: 1,
string: 'hello',
number: 1000,
boolean: true,
inherited: true
}
]
}
})