lundi 12 septembre 2016

EmberJS 2.7 - download an externally hosted file on route transition (but only once)

I have this code in a route:

import Ember from 'ember';

export default Ember.Route.extend({
  isEditing: true,

  beforeModel: function() {
      return Ember.$.getScript('//api.filestackapi.com/filestack.js');
  }
});

But is this the correct way, will it download this file every time a user transitions to this route?

I tried this solution, but in that run loop the DOM is already rendered, but I need this file to render the page, so that does not work. I also tried to remove the Run loop call, but it seems to no longer work in Ember 2.7 (I got a deprecated warning and the app just failed to load anything!).




Aucun commentaire:

Enregistrer un commentaire