Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember.JS view not rendering?

Tags:

ember.js

Maybe I'm missing something, but I'm really confused as to why this isn't working:

// The Javascript
App.UsersView = Ember.View.extend({
    templateName: 'user-list'
});

// The HTML
<script type="text/x-handlebars" data-template-name="user-list">
    Hello World
</script>

Nothing is displaying?

(The application view displays so it's not a problem with the way ember.js is loaded. Just when trying to use custom views.)

like image 865
andy Avatar asked Aug 11 '26 10:08

andy


1 Answers

The only view/template that is automatically appended to the dom is application. To include UsersView on the page, try:

<script type="text/x-handlebars" data-template-name="application">
  <pre>application view</pre>
  {{view App.UsersView}}
</script>

Working example here: http://jsbin.com/iluvik/1/edit

Typically the view helper is not necessary as most of the views/templates your application will get created by the ember router. Have a look at the Ember Routing Guide for a better understanding of how to wire things up.

like image 108
Mike Grassotti Avatar answered Aug 13 '26 01:08

Mike Grassotti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!