javascript - Ember JS,Pass input tag value as parameter in action handlbars -


i want value <input> tag , pass parameter action in emberjs

when used jquery {{action 'add' this.$('#x').val()}} ember failed build giving parse error on line ...

here want pass x , y parameter {{action}}, know syntax sending parameters {{action parameter1 parameter2 ..etc}}

templates\alpha.hbs

<h1>alpha template</h1> <div>  <label>x value</label>  <input type="text" id="x">  <label>y</label>  <input type="text" id="y">  <input type="button" id ="add-button" value="add" {{action 'add' }}> </div> 

controllers\alpha.js

import ember 'ember';  export default ember.controller.extend({   actions:{     add: function(x, y){       alert('this done right '+x+ ' ' + y);     }   } }); 

i tested code without passing parameters , code worked expected giving alert required

you need take advantage of input helpers , value binding in ember:

<br><h1>alpha template</h1> <div>  <label>x value</label>  {{input value=xvalue}}  <label>y</label>  {{input value=yvalue}}  <input type="button" id ="add-button" value="add" {{action 'add' xvalue yvalue}}/> </div> 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -