ember.js - how to really find out only once if Ember finishes its ajax request and DS.RecordArray is completely filled -


i have tried gazillion ways , nothing efficient. last attempt - works little ugly tradeoff this:

app.usersroute = em.route.extend({   model: function() {     return app.user.find({}).then(function(response) {       return response;     });   } }); 

the problem - i'd love know making synchronous call. html/dom won't finish loading until returns.

another thing i'd love know if omit empty object {} find - promise function gets called immediately. promise!

now other methods i've tried following have flaws:

  • observing content.lastobject.isloaded on controller
  • implementing arraycontentdidchange ember.arraycontroller - gets triggerd multiple times array getting filled. -

i have tried gazillion ways , nothing efficient.

i don't know if tried hooking aftermodel function of route addition added not long ago , available in rc6:

app.usersroute = em.route.extend({   aftermodel: function(users, transition) {     console.log(users.get('length'));   } }); 

see here more info on hooks beforemodel , aftermodel.

i've put togheter jsbin play around.

hope helps.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -