ui-sortable icon indicating copy to clipboard operation
ui-sortable copied to clipboard

sorted array is not retained

Open jyoti-openair opened this issue 5 years ago • 1 comments

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 ?

jyoti-openair avatar Jan 14 '19 13:01 jyoti-openair