vendredi 14 octobre 2016

Ember: Make change to the model inside didLoad

I want to make some changes to my model from the didLoad method. I am using it to play a sound once and set the flag to not play it again. Even though in the console I am seeing the log called from within successful callback, the changes are not persisted. How can I make sure they are persisted?

  didLoad:function(){
      console.log("Did load");
       if(this.get('shouldPlay')){
      var mySound = soundManager.createSound({
        url: 'assets/beep22.mp3'
      });
      mySound.play();
      this.set('shouldPlay','false');
      this.save().then(() => {
          console.log("saved");
      },(error)=>{
          console.log(error);
      });
    }
  }




Aucun commentaire:

Enregistrer un commentaire