mardi 28 avril 2015

How do you use Ember.js addons?

I evaluating Ember.js for possible use in an upcoming project. I want to see now it fares with a long list item, so I tried to installed the ember-list-view.

I ran the command:

ember install:addon ember-list-view

The syntax seems to have changed, so I ran

ember install ember-list-view

That activates npm, which downloaded the package successfully. I can see it in node_modules. Then per the documentation I created the following:

templates/test.hbs:

{{#view 'list-view' items=model height=500 rowHeight=50 width=500}}
  {{name}}
{{/view}}

routes/test.js

import Ember from 'ember';

// define index route and return some data from model
export default Ember.Route.extend({
  model: function() {
    var items = [];
    for (var i = 0; i < 10000; i++) {
      items.push({name: "Item " + i});
    }
    return items;
  }
});

I added the route in router.js. When I go to the page, nothing shows up. According to Ember Inspector, the right template was being used and the data was there. A check on Ember.ListView in the console yield undefined.

Is there something more that needs to be done to bring in the code? Searches in the Ember and Ember-CLI documentation yielded no answer.




Aucun commentaire:

Enregistrer un commentaire