Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

sorted array is not retained #560

Open
jyoti-openair opened this issue Jan 14, 2019 · 1 comment
Open

sorted array is not retained #560

jyoti-openair opened this issue Jan 14, 2019 · 1 comment

Comments

@jyoti-openair
Copy link

jyoti-openair commented Jan 14, 2019

So, I have an array as

var groups = [{
  name: 'Applicants',
  place: 'NY'
},{
  name: 'Volunteer',
  place: 'CA'
},{
  name: 'Others',
  place: 'LA'
}];

so when I drag and sort it. I'm saving it to cookies. as follows:

var groupsObj = {
    groups: ui.item.sortable.droptargetModel
}
$cookies.putObject('groups', groupsObj);

when I console.log ui.item.sortable.droptargetModel it gives me correct sorted array. ex:

[{
  name: 'Applicants',
  place: 'NY'
},{
  name: 'Others',
  place: 'LA'
},{
  name: 'Volunteer',
  place: 'CA'
}];

But when I get the cookies as follows:

$cookies.getObject('groups');
it's giving me initial array instead of sorted array.

[{ name: 'Applicants',
  place: 'NY'
},{
  name: 'Volunteer',
  place: 'CA'
},{
  name: 'Others',
  place: 'LA'
}];

I'm not sure what the problem is, is it reference problem ?

@thgreasi
Copy link
Contributor

thgreasi commented Apr 4, 2019

It could be.
Can you try doing droptargetModel.slice() ?
Also in which option are you setting b the cookie?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants