vendredi 23 janvier 2015

Ember.js - afterRender fires before CSS is finished

I'd like to show a loading symbol while my validation is processing. My .hbs file looks like this



<div {{bind-attr class='isProcessing:spinner'}}></div>


I tried to wrap my validations into the afterRender run loop, but apparently afterRender doesn't mean after-CSS. My validations are executed before the css class of the div changes (It doesn't change at all).



App.PostController = Em.Controller.extend({

isProcessing: false,

actions: {

savePost: function() {

this.set('isProcessing', true);

Ember.run.scheduleOnce('afterRender', this, function() {

// do a lot of validating and other (non-asynchronous) stuff here
// ... this may take several seconds

this.set('isProcessing', false);
});
}
}
});


What can I do that my code starts to execute after all CSS rendering is done?


I also tried Ember.run.next. This doesn't work either. Ember.run.later works with a timeout of at least about 200ms but of course I don't want to hardcode any static timespan.


Any held would be apprechiated! Thanks in advance!





Aucun commentaire:

Enregistrer un commentaire