Backbone Marionette Displaying before fetch complete

前端 未结 3 1314
抹茶落季
抹茶落季 2021-01-06 12:51

I know i am doing something stupid but my backbone marionette app is giving me template errors that don\'t make sense. It appears to be rendering a single item before the fe

相关标签:
3条回答
  • 2021-01-06 13:27

    Modified the Model to have a default value of anything i want to template. Feels Klugy but it gives me an app that works.

    MyApp.Tag = Backbone.Model.extend({
        defaults :
            {
                TagName : 'None'
            }
    });
    
    0 讨论(0)
  • 2021-01-06 13:28

    The problem is this line in your initializer

    var tagCollection = new MyApp.TagCollection({
        });
    

    When you pass an empty object literal in to a Backbone.Collection constructor, Backbone creates an empty model in the collection. To fix this, just remove the object literal:

    var tagCollection = new MyApp.TagCollection()

    and it won't have the empty item in it anymore.

    0 讨论(0)
  • 2021-01-06 13:46

    Try:

    tagCollection.fetch({ wait: true });
    
    0 讨论(0)
提交回复
热议问题