Skip to content

Instantly share code, notes, and snippets.

@patrickberkeley
Last active July 21, 2016 21:29
Show Gist options
  • Save patrickberkeley/3901bf2bf11c65cff1b5 to your computer and use it in GitHub Desktop.
Save patrickberkeley/3901bf2bf11c65cff1b5 to your computer and use it in GitHub Desktop.
New Twiddle
import DS from 'ember-data';
export default DS.FixtureAdapter.extend();
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
isVisible: false,
actions: {
toggleInput() {
this.toggleProperty('isVisible');
},
submit() {
this.get('model').save();
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.createRecord('my-model');
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
<button {{action 'toggleInput'}}>
Toggle that input!
</button>
{{#if isVisible}}
{{input
value=model.someProperty
insert-newline=(action 'submit')
}}
{{/if}}
<br>
<br>
Let's see that model property:
<br>
{{model.someProperty}}
import DS from 'ember-data';
const {
attr
} = DS;
const MyModel = DS.Model.extend({
someProperty: attr('string')
});
MyModel.reopenClass({
FIXTURES: [
{
id: 1,
someProperty: 'Dickinson'
},
{
id: 2,
someProperty: 'Twain'
}
]
});
export default MyModel;
{
"version": "0.5.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "1.13.13",
"ember-data": "1.13.15",
"ember-template-compiler": "1.13.13"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment