1

So basically, I created a Backfire app. As soon as the page is loaded, I am iterating over my Backbone.Firebase.Collection instance.

And then rendering the results onto the page... the problem is that obviously the collection instance does not contain all the data that is on firebase.

So, I put a set-timeout of 1000ms to make it so that the collection has time get its data from Firebase. This way of doing it is terrible... sometimes the data is synced up other times it is not.

How can I have an event be triggered as soon as the "BackFire Collection Model" has its data from firebase?

$(document).ready(function() {
  var myCatalogApp = new CatalogApp()
  var catalog = new Catalog()

  setTimeout(function(){myCatalogApp.displayCollection(catalog)},1000);
  //To give catalog time to asynchronously retrieve database entries
  myCatalogApp.initialize()
})

var Catalog = Backbone.Firebase.Collection.extend({
  model: Item,
  firebase: "https://mycatalogmaker.firebaseIO.com/items"
});

All of my problems would be solved if Backfire would let me do a fetch method... but they have it disabled for Backfire objects

1 Answers1

0

Try this :

$(document).ready(function() {
  var myCatalogApp = new CatalogApp()
  var catalog = new Catalog();

  catalog.bind('sync', function(){myCatalogApp.displayCollection(catalog);});

  myCatalogApp.initialize();
})        
Rida BENHAMMANE
  • 4,111
  • 1
  • 14
  • 25