I am generating json and storing it as a data attribute. e.g.
data-categories="{"2":{"categoryId":"2","name":"how to's"},"5":{"categoryId":"5","name":"about us"},"6":{"categoryId":"6","name":"proucts"}}"
When I later try to edit and save the new json it is not being saved and the old dat still exists.
e.g.
//get the existing categories
var currentCategories = $('li#'+ $(this).data('backgroundid')+' .categoryTags .addCategory').data('categories');
//get then name and if from the at to link
var newCategory = {'tagid': $(this).data('categoryid'), 'name': $(this).data('categoryname')}
currentCategories=[$(this).data('backgroundid')].push(newCategory);
//when I log the object here it is fine contains the old categories and the new category
//save the new string back to the data attribute of li elsewhere on page
$('li#'+ $(this).data('pageid')+' .categoryNames .addCategory').data('categories',currentCategories);
But the the data is still the same in the dome and when I try to reference it later