jeudi 25 juin 2015

How to remove and object from an array in Ember

I don't understand why the object is not removed from the array. I tried to implement this solution Ember.js how to remove object from array controller without ember data but the object is not removed from the previousParent.

changeCauseLinkParentRt(newParent, causeLink) {
  if(!newParent) {
    causeLink.get("parent").then(previousParent => {
      previousParent.get("children").then(children =>{
        var _newParent = children.findBy("order", causeLink.get("order")-1);
        if(!!_newParent) {
            var objRemove = null;
            previousParent.get("children").then(children => {
              objRemove = children.findBy("id", causeLink.get("id"));
              children.removeObject(objRemove);
              children.save();
              causeLink.set("parent", _newParent);
              causeLink.save();
              _newParent.get("children").pushObject(causeLink);
              _newParent.save();
            });
          }
        });
      })
  } else {
    //...
  }
},




Aucun commentaire:

Enregistrer un commentaire