Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

bbb todomvc not rendering item list #59

Closed
TrisDing opened this Issue · 3 comments

3 participants

TrisDing Tim Branyen Drawyan
TrisDing

So not sure it's a bug or am I doing something wrong...

Views.List = Backbone.View.extend({
  tagName: "ul",

  render: function(manage) {
    this.collection.each(function(item) {
      this.insertView(new Views.Item({
        model: item
      }));
    }, this);

    return manage(this).render();
  },

  initialize: function() {
    this.collection.on("reset", function() {
      this.render();
    }, this);

    ......

When you say list.fetch() in the router.js, the collection will trigger reset event and call this.render(). However, this.render() is not refering the render() function above (I guess it's trying to delegate to the layout manager's render function but failed). Instead, it's calling LayoutManager.view.render() directly and completely ignore the render() function in the above code. And that cause the list not rendering anything.

I changed the code as follows and it worked

Views.List = Backbone.View.extend({
  tagName: "ul",

  beforeRender: function() {
    this.collection.each(function(item) {
      this.insertView(new Views.Item({
        model: item
      }));
    }, this);
  },

  initialize: function() {
    this.collection.on("reset", function() {
      this.render();
    }, this);

    ......
Tim Branyen
Owner

Ah that's not good, thanks for the heads up!

Drawyan

You Saved My Life, this is exactly what I've been encountered!

Tim Branyen
Owner

I've removed the TodoMVC app for now. May revisit in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.