Variables, Passing Parameters, and Functions

Variables, Passing Parameters, and Functions

Hey guys,

I am working on an app and have reached a standstill on somthing I thought would be simple. I need to access a variable that I am setting from a click/tap event in a pagebeforehide event. Am I insane? Is this impossible?? See below:

  1. $('.list_title').live('tap click', function(event) {
  2.         listID = $(this).attr('id').replace('list-', '');
  3. //setting the listID here when a user clicks. want to use it later.
  4. });

  5. $('#add_list, #erase_all').live('pagebeforehide',function(event, ui){
  6. alert(listID);
  7.         //always comes back undefined. What the heck? What am I doing wrong?
  8. });
Any thoughts on how I am doing this wrong?

Even declaring the variable as "global" (not stating 'var') does not allow this variable to be accessed. Any help would be greatly appreciated!