How to prevent Backbone.Marionette from rendering a view if it's model hasn't been fetched?

前端 未结 4 672
暗喜
暗喜 2020-12-31 10:08

In my backbone.Marionette application I have a Model that requires an Id attribute to construct it\'s url. I therefore create the model by passing it an Id, add it to a view

4条回答
  •  情书的邮戳
    2020-12-31 10:31

    based on one of Derick Bailey's examples:

     model = new Model({_id:id})               
       var fetched = model.fetch();
    
      // wait for the model to be fetched
      $.when(fetched).then(function(){
    
         view = new View({model:model})                               
         app.content.show(view)     
      });
    

提交回复
热议问题