vendredi 3 février 2017

ember persistantly save sorted model

I am using this drag and drop addon for ember: ember-drag-drop So far so good, this works as expected. I copied the controller- and template code from the demo (ember-data) and adapted it to my model. In my template the records of my model are sorted with drag and drop and are displayed in another list on this site correctly (is updating at the same time as the drag and drop list).

Now, what should I do to permanently save my sorted records ? Somehow this model must have changed, otherwise the other list would not recognise this or am I wrong ? Maybe anyone who used this addon came across this, too.

Normally, my records are stored in local storage. For that, I use the ember-local-storage-adapter. I tried the following: My model is called buttons. Inside the model there are several records.

const store = this.get('store');    
store.findAll('buttons').then(function(sorted){
         console.log(sorted);
         sorted.save();
       });

It seems that with this I only get the old model from the local storage but actually I need the most recent model that lives somewhere on the site.

I hope you understand, what I am struggeling with my mind is running out with all these model stuff.

Thanks for any help and suggestions!




Aucun commentaire:

Enregistrer un commentaire