Backbone.js: Elegant way to check if data ready and if the dataset is empty

后端 未结 3 1751
孤街浪徒
孤街浪徒 2021-01-04 04:09

I\'m looking for a better solution for two things:

  • How can I understand if the data is fetched and ready, I use BasicDealList.on(\"reset\", function()

3条回答
  •  青春惊慌失措
    2021-01-04 04:30

    We needed a way to tell if a RelationalModel's relation had been fetched or not. This is our solution (in Coffeescript).

    initialize: (objects, options) ->
      @fetched = false
      @listenTo @, 'sync', -> @fetched = true
    

提交回复
热议问题