Skip to content

Instantly share code, notes, and snippets.

@HERRKIN
Created February 9, 2015 20:39
Show Gist options
  • Save HERRKIN/d82572169c8914bbfa7e to your computer and use it in GitHub Desktop.
Save HERRKIN/d82572169c8914bbfa7e to your computer and use it in GitHub Desktop.
problem with view select
//item controller for article
import Ember from 'ember';
export default Ember.Controller.extend({
states: ['borrowed', 'returned'],
autoSave: function() {
if (!this.get('model.isNew')) {
this.send('save', this.get('model'));
}
},
isDirtyChanged: function() {
if(this.get('model.isDirty')===true){
console.log(this.get('model.isDirty'));
}
if (this.get('model.isDirty') && !this.get('model.isSaving')) {
Ember.run.once(this, this.autoSave);
}
}.on('init').observes('model.isDirty')
});
//template for articles index
<h2>Articles Index</h2>
<table class="primary">
<thead>
<tr>
<th>Description</th>
<th>notes</th>
<th>Borrowed since</th>
<th></th>
</tr>
</thead>
<tbody>
{{#each itemController='articles/item'}}
<tr>
<td>{{model.description}}</td>
<td>{{model.notes}}</td>
<td>{{formatted-date model.createdAt 'LL'}}</td>
<td>
{{#if model.isSaving}}
Saving ..
{{else}}
{{view 'select' content=states selection=model.state}}
{{/if}}
</td>
</tr>
{{/each}}
</tbody>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment