ember.js - Ember-rails: function returning 'undefined' for my computed value -
Both functions are 'undefined' here I can not understand what the problem is. It seems that straight-forward What is it ??
In the controller I have set some properties to present the user with an empty text field so that they can be sure to type in their data.
Amber. Product Controller = Amber Object Controller Extension ({quantity_property: "", location_property: "", employee_name_property: "", // quantity substrate: function () {// Return to 'get' ('quantity') - = this.get ('quantity_property' );;} .property ('quantity', 'quantity_property') Quantity subtrace: Ember.computed ('quantity', 'quantity_property', function () {return this.get ('quantity') - this.get (' Quantity_property ');});});
Enter the route, setting both employee name and location ...
Amber Projects Deduct-Route = Ember.Route.extend ({Model: Functions (Parameters) {return.store.find ('product', params.product_id);}, // This defines the verbs that we display in the template actions Get it: {update: function} {var product = this get ('current model'); var self = this; // Expression of success ensures the access to the function (*) * * Then the first parameter of 'success' is handler, where it changes the list of products , And the second parameter is our failure handler: A function that does nothing. * / Product.set ('employee name', this.get ('controller.employee_name_property')) product.set ('location', this.get ('Controller. Location_property')) product.set ('quantity', this.get ('controller.quantitySubtract ()')) product.save (). Then (function () {self.transitionTo ('products')} , Function () {}};}}});
Nothing is more specific in the handler
& lt; H1 & gt; Product Forbig & lt; / H1> & Lt; Form {{Action "Update" on "Submit"}} & gt; ... & lt; Div & gt; & Lt; Label & gt; Antal & lt; Br> {{Input type = "text" value = quantity_property}} & lt; / Label & gt; {{Errors.quantity error in error}}} & lt; P class = "error" & gt; {{Error.message}} & lt; / P & gt; {{/ Every}} & lt; / Div & gt; & Lt; Button type = "update" & gt; Save & lt; / Button & gt; & Lt; / Form & gt;
get rid of ()
product.set ('Quantity', this.get ('controller.quantitySubtract'))
And it was okay:
< Code> Volume Subtract: Function () {return.get ('Quantity') - this.get ('quantity_property'); } .property ('quantity', 'quantity_property')
updates:
By looking at your route, that controller will not be applied to that route, it's okay Is a normal Ember.ObjectController
.
Amber.ProductUpdateController
by using
Amber.ProductController
You must go to Amber.ProductUpdateRoute
If you want to reuse the controller for both routes, then just expand the product controller. (
Comments
Post a Comment