Preferred Way To Retrieve Data From A Template In Emberjs
I'm trying to get some data out my templates to, let's say, add an user. This is what my view object looks like: Ember.View.create({ template: Ember.Handlebars.compile( UsersIn
Solution 1:
You should use bindings to bind the values in your template to properties on your view, see an example http://jsfiddle.net/pangratz666/uuvAp/:
Handlebars:
<scripttype="text/x-handlebars"data-template-name="my-template" ><!-- bind value of TextField to property username of view -->
Username: {{view Ember.TextField valueBinding="view.username"}}
<button {{actionaddUser}}>addUser</button></script>
JavaScript:
Ember.View.create({
templateName: 'my-template',
addUser: function(event){
var username = this.get('username');
console.log('add user with name: %@'.fmt(username));
}
}).append();
Solution 2:
You can use the available insertNewline for handling the value.
See this fiddle http://jsfiddle.net/z5SNW/6/
Post a Comment for "Preferred Way To Retrieve Data From A Template In Emberjs"