Skip to content

Instantly share code, notes, and snippets.

@joshhornby
Created May 7, 2015 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshhornby/7eaf7ee94bd68676f717 to your computer and use it in GitHub Desktop.
Save joshhornby/7eaf7ee94bd68676f717 to your computer and use it in GitHub Desktop.
Ember Modal - Multiple models
import Ember from 'ember';
export default Ember.Controller.extend({
isValid: Ember.computed(
'model.name',
function() {
return !Ember.isEmpty(this.get('model.name'));
}),
actions: {
approve: function(view) {
var _this = this;
// For some reason this is putting to the database, it things it has an instance of the wrong modal
if (this.get('isValid')) {
this.get('model').save().then(function(friend) {
view.execute('hide')
this.transitionToRoute('project', friend);
});
} else {
console.log('error');
}
},
closeModel: function() {}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
this.store.createRecord('project')
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
confirm: function() {
// https://github.com/Semantic-Org/Semantic-UI-Ember#controller-model
this.send('openModal', 'projects/confirm', this.get('model'));
}
}
});
import Ember from 'ember';
import SemanticRouteMixin from 'semantic-ui-ember/mixins/application-route';
export default Ember.Route.extend(SemanticRouteMixin,{
model: function() {
return this.store.findAll('project');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment