Frage

Have someone tried to observe isSaving attribute with Ember 1.0.0, which just releases last week. It seems does not work.

Here is the code:

var tempObject= HubStar.Mega.createRecord({
});

tempObject.addObserver('isSaving', function() {
        if (mega.get('isSaving')) {
   console.log('isSaving');
        }
        else {
      }
          console.log('isSaved');
    });

App.store.save();

I know there is some changes, but how I can observe the object with the new Ember version? Is it there another way to do that?

War es hilfreich?

Lösung

Looking at the transition guide https://github.com/emberjs/data/blob/master/TRANSITION.md you could try something like:

this.store.createRecord('mega')
tempObject.one('isSaving', function(){ ... });

this.store.save();

Accessing the Store and creating/finding records has also changed. Although am not 100% sure those event still exist or will continue to exist in favour of promises?

Andere Tipps

Thanks for your reply, Colymba. I have tried your method, but it does not work.

However, from the transition guide, I found another solution. Something like this: mega.save().then(function() { // work with saved person // newly created records are guaranteed to have IDs assigned }, function() { // work with person that failed to save });

The interesting thing is, when a record is saved, it runs the second function(), but not the first one. Is something wrong I made?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top