lundi 22 décembre 2014

Operations with Select value and Input value in Ember

It's still not really clear to me how can ii can make operations with the Select option values in Ember


This is very simple moltiplication i want to achieve between a value of an Input and Select option value


My code is the following:


My input quantity: {{input valueBinding=quantity}}


My Select with the option value: {{view Ember.Select prompt="Tariffa" value=selectContentTariffa.value content=controller.selectContentTariffa optionValuePath="content.value" optionLabelPath="content.label"}}


My Input total where i want to show the moltiplication result between quantity and the selected fare:



{{view "total"}}

<script type="text/x-handlebars" data-template-name="total">
{{view.total valueBinding=total}}
</script>


This is the view where i set up the moltiplication



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('selectContentTariffa.value')) * parseInt(this.get('quantity'));
return isNaN(res)?"":res;
}).property('selectContentTariffa.value', 'quantity')
});


Am i doing something wrong in setting up the values this.get('selectContentTariffa.value')) or this.get('quantity')) ?


or i am doing an other mistake?


Here i have reproduced my case





Aucun commentaire:

Enregistrer un commentaire