Monday, 15 February 2010

javascript - ValueBinding not working on adding new Object in my Ember view -



javascript - ValueBinding not working on adding new Object in my Ember view -

i have input field type number result of multiplication of 2 values displayed.

i have set total function valuebinding in html

here ember.view.extend total calculation

app.totalview = ember.view.extend({ templatename: 'total', tagname: 'input', attributebindings: ['total:value', 'placeholder', 'type'], placeholder: null, type: 'number', total: (function() { var res= parseint(this.get('controller.newthread.selectcontenttariffa')) * parseint(this.get('controller.newthread.primary')); homecoming isnan(res)?"":res; }).property('controller.newthread.selectcontenttariffa', 'controller.newthread.primary') });

i have defined calls newthread

newthread:function(){ homecoming {selectcontenttariffa:null,primary:null,total:null,weight:null}; }.property(),

this html when select values calculation: valuebinding=newthread.selectcontenttariffa, valuebinding=newthread.primary , valuebinding=newthread.total total result

<tr> <td>{{view ember.select prompt="tariffa" valuebinding=newthread.selectcontenttariffa content=selectcontenttariffa optionvaluepath="content.value" optionlabelpath="content.label"}} </td> <td>{{view em.textfield type="number" valuebinding=newthread.primary class="form-control"}} </td> <td>{{view "total" valuebinding=newthread.total}}</td> <td><button class="btn btn-success" {{action add together item}}>add</button></td> </tr> <script type="text/x-handlebars" data-template-name="total"> {{view.total valuebinding=newthread.total}} </script>

this html there values displayed after have added them

{{#each item in model}} <tr> <td>{{item.selectcontenttariffa}}</td> <td>{{item.primary}}</td> <td>{{item.total}}</td> </tr> {{/each}}

i dont't know missing, have reproduced issue here : http://emberjs.jsbin.com/qakado/13/edit?html can see value of result in lastly column under not bound

the total property of object assigned newthread property never set result. approach create total property calculated property , carry out multiplication there. display property within view.

http://emberjs.jsbin.com/vivohiyefu/1/edit?html,js

javascript model-view-controller ember.js jsfiddle jsbin

No comments:

Post a Comment