Skip to content

Instantly share code, notes, and snippets.

@kenelliott
Last active October 8, 2015 18:56
Show Gist options
  • Save kenelliott/c47bf0dcca915f53399f to your computer and use it in GitHub Desktop.
Save kenelliott/c47bf0dcca915f53399f to your computer and use it in GitHub Desktop.
New Twiddle
import DS from 'ember-data';
export default DS.ActiveModelAdapter;
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Route.extend({
init() {
this._super(...arguments);
$.mockjax({
url: '/widgets',
response() {
console.log('yep');
this.status = 403;
this.responseText = "temporarily unavailable";
}
});
},
model() {
return this.store.createRecord('widget', {name: "foo"});
},
actions: {
save() {
this.get('currentModel').save().then(() => {}, response => {
console.log('error caught', response);
});
}
}
});
import DS from 'ember-data';
export default DS.ActiveModelSerializer.extend();
<h1>Welcome to {{appName}}</h1>
<div style='margin-top:10px; margin-bottom: 10px;'>
{{input type="text" value=model.name}}
</div>
<button href="" {{action "save"}}>Save</button>
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string')
});
{
"version": "0.4.11",
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "http://builds.emberjs.com/tags/v1.13.5/ember.debug.js",
"ember-data": "http://builds.emberjs.com/tags/v1.13.5/ember-data.js",
"ember-template-compiler": "http://builds.emberjs.com/tags/v1.13.5/ember-template-compiler.js",
"jquery-mockjax": "https://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.6.2/jquery.mockjax.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment