mardi 24 janvier 2017

jQuery library not loading in Ember

I am using jPlayer inside my application. I have a component called player-button in which I create the jPlayer.

export default Ember.Component.extend({
  didInsertElement: function () {
    Ember.run.scheduleOnce('afterRender', this, function () {
      console.log(this);
      Ember.$("#jquery_jplayer_1").jPlayer({
        ready: function () {
          $(this).jPlayer("setMedia", {
            title: "Bubble",
            m4a: "http://ift.tt/1rgfaht",
            oga: "http://ift.tt/1nvykNf"
          });
        },
        cssSelectorAncestor: "#jp_container_1",
        supplied: "m4a, oga"
      });
    })
  }
});

On my template called station I have it render a button that will start the playback.

For some reason if I open the page at the /station endpoint the player loads fine, but if I navigate from /home to /station it tells me $(...).jPlayer is not a function

Why is this?




Aucun commentaire:

Enregistrer un commentaire