@hschillig wrote:
I have a model called
contractf
which has a computed property calledsale_price
.sale_price: function() { return this.get('dealers_sched_id').get('sale_price'); }.property("dealers_sched_id.sale_price"),
dealers_sched_id
refers to a relationship to a model calledsched
.sched
has a computed property calledsale_price
:sale_price: Ember.computed('pacfee', 'sponsor_comm', 'agent_comm', 'pass', 'fi_comm', 'total_tp_cost', 'reserve_amount', function() { var pacfee = this.get('pacfee'); var sponsor_comm = this.get('sponsor_comm'); var agent_comm = this.get('agent_comm'); var pass = this.get('pass'); var fi_comm = this.get('fi_comm'); var total_tp_cost = this.get('total_tp_cost'); var reserve_amount = this.get('reserve_amount'); var sale_price = pacfee + sponsor_comm + agent_comm + pass + fi_comm; sale_price = sale_price / 100; return sale_price + total_tp_cost + reserve_amount; }),
I'm trying to get the totals of all the contract models that are selected. This is on my controller and then in my template, I call
{{new_suggested_price}}
. I have the selection populating fine:new_suggested_price: Ember.computed('selectedItems', '[].sale_price', function() { var ret = 0; this.get('selectedItems').filterBy('car_used', 'N').forEach(function(contract){ console.log(contract.get('sale_price'); if (contract.get('sale_price')) { ret += (contract.get('sale_price')*100); } }); return ret/100; // We *100/100, so we avoid a floating point calc error. }),
However, on page load,
contract.get('sale_price')
is coming back as NaN (even though the record is pulling fine), but if I set asetTimeout
function and then render it after 500ms or whatever, it comes back the correct value it's suppose to be.How do I go about making this populate on page load? Thank you!
Posts: 1
Participants: 1