sorted array is not retained
jyoti-openair opened this issue · 1 comments
jyoti-openair commented
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 commented
It could be.
Can you try doing droptargetModel.slice()
?
Also in which option are you setting b the cookie?