Reputation: 2323
I'm rendering a model into a parent template like this:
{{render "teacher" teacher}}
Here's it's controller:
App.TeacherController = Ember.ObjectController.extend(App.EditableModelMixin, {
actions: {
saveTypes: function() {
if (this.get('model')) console.log('Exists');
console.log(this.get('model'));
console.log(this.get('model').get('isFulfilled'));
this.get('model').save();
}
}
});
Here's the output when this method is called:
Exists
Class {isFulfilled: true, toString: function, constructor: function, reason: null, isPending: undefined…}
true
Uncaught TypeError: Object [object Object] has no method 'save'
This way of doing things has had no problems for me before. It only seems to happen when I use render
.
Update
Here's a screen shot of me looking at the TeacherController
in Ember Inspector:
And another of just my view hierarchy:
Upvotes: 2
Views: 134
Reputation: 47367
It appears as if that model is a PromiseObject (from an async mapping). Promise objects are an extension of Ember.ObjectProxy which will proxy property calls down to the real model if it exists, but the methods aren't proxied.
var modelPromise = this.get('model');
modelPromise.then(function(actualModel){
actualModel.save();
});
Upvotes: 2