I’m trying to understand the basic concepts of ember.js and how the whole template/view stuff works together (and some best practices), but, I really have problems to find answers to my questions…. So, maybe, one of you can help me…
-
“Getting started” says: “You can use Ember.View to render a Handlebars template and insert it into the DOM” and it suggests the usage of view.append(). I downloaded to getting started kit and there is a template, a view and it’s beeing displayed without a view.append(). Why?
-
I tried to extend the template with a placeholder {{ message }} added a attribute with the same name to the view, and assigned a value, but its not rendered. Why?
Can someone please bring some light to me… Many thanks in advance. Links and good Stackoverflow threads are very welcome.
Some code examples:
index.html:
<script type="text/x-handlebars" data-template-name="application">
<h1>Hello from Ember.js</h1>
</script>
app.js
App.ApplicationView = Ember.View.extend({
templateName: 'application',
message : 'Hallo Du'
});
If I change ‘application’ to ‘application_”, it will still be rendered… So, why do I define a template name?
Best regards
Peter
Like I said in the comments, in Ember 1.0pre (and newer releases), to display view attributes/properties you have to do
{{view.YourAttributeName}}, so you have to user{{view.message}}in your handlebars template. So here’s what you have to do in your js:And here’s the html page with the template:
Check this very basic fiddle with the code above working: http://jsfiddle.net/schawaska/MwXjG/