0

I'm doing what should be fairly easy, I'm creating a cookie which holds a bunch of user defined variables and puts them into a list.

I am then trying to allow the person to delete an item from the list, which will remove it from the cookie.

The code to remove an item from the list looks like this

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'));
});

I'm using the code I found on this page to build a comma seperated list to the items, and to get the items. how to store an array in jquery cookie? I've also tried using the userList.clear() to delete the cookie, but that hasn't worked either.

Community
  • 1
  • 1
pedalpete
  • 21,076
  • 45
  • 128
  • 239

1 Answers1

0

jQuery.cookie(...) is generating 'Object does not support this property or method'

Have you correctly included a link to the JQuery cookie plugin script?

http://plugins.jquery.com/node/1386/release

Same problem with this line

holdList.items() is generating 'Object does not support this property or method'

Doug Chamberlain
  • 11,192
  • 9
  • 51
  • 91
  • If I'm understanding what you're seeing doug, it is that YOU don't have the cookie plugin included. Yes, I have the cookie plugin. I am creating the cooking, showing the cookie, but can't delete it. Or have I misunderstood what you're saying? – pedalpete Jan 07 '11 at 21:35
  • Your right I didn't have it at first. I edited my answer to the second issue. I figure start at the easiest solution (missing the js reference). – Doug Chamberlain Jan 07 '11 at 21:41
  • I am getting no such error Doug, and I can alert holdList.items() and get back the cookie items. – pedalpete Jan 07 '11 at 21:44