backbone.js structuring nested views and models

前端 未结 5 1056
感情败类
感情败类 2020-12-02 03:51

Using backbone.js:

I have a top level ModelA that contains 2 attributes and 2 nested models, ModelB and ModelC. ModelB and ModelC each have 2 attributes as follows:<

5条回答
  •  死守一世寂寞
    2020-12-02 04:43

    The above solution is on the right track but has some problems.

    initialize: function(){
      this.viewB = new ViewB();
      this.viewB.parentView = this;
      $(this.el).append(this.viewB.el);    
    }
    

    Mainly, the model's toJSON() now returns stale data. I've posted a solution to fix this problem in a backbone.js plugin. You're welcome to use it.

提交回复
热议问题