Я делаю то, что должно быть довольно просто, я создаю cookie, который содержит набор пользовательских переменных и помещает их в список.
Затем я пытаюсь разрешить человеку удалить элемент из списка, который удалит его из файла cookie.
Код для удаления элемента из списка выглядит следующим образом
jQuery('a.removeFromList').live('click', function(){
// put the userList into a holder so I can go through the variable list and only remove the one the user clicked
var holdList=userList;
// delete the entire userList
jQuery.cookie('userList',null,{ expires: -1 });
// go through the holdList
for(or=0;or<holdList.items().length;or++){
// this should return "null", but doesn't
alert(userList.items());
if(holdList.items()[or]!=jQuery(this).attr('id')){
// this is a function which adds the data to the cookie.
userList.add(holdList.items()[or]);
}
}
showList(userList,jQuery('ul#userList').data('data'));
});
Я использую код, найденный на этой странице, для создания списка элементов, разделенных запятыми, иполучить предметы. как сохранить массив в jquery cookie? Я также пытался использовать userList.clear () для удаления cookie, но это тоже не сработало.