Im starter with ember, my question simple, I want to append a handlebar in my html, simple, but the append (in all my experiments) only work when I wrapp it with $(function(){…}). I dont want to use that (if its possible….). Any alternative, solution, suggestion?
<!--handlebar-->
<script type="text/x-handlebars" data-template-name="text">
<h1>Send the message:</h1>
<input {{action "clicked" on="click"}} {{bindAttr name="name_attribute"}} value='click me!!' type="button"/>
</script>
<script>
//namespace
App = Ember.Application.create();
//define view
App.myview = Ember.View.extend({
templateName: 'text',
name_attribute:'name_buttooooon',
message: '',
clicked: function(event) {
jQuery('#templateHere').html((this.get('name_attribute')));
}
});
//create view
App.myview=App.myview.create();
//insert view in body
$(function() {
App.myview.append('#templateHere'); //Why I need to wrap this line in $(function(){..})???
});
</script>
<div id="templateHere"></div>
</body>
Use
Ember.Application.readyto perform operations once the app has loaded: