So i have the global variable
var INSIDE_GLOBAL = {} ;
INSIDE_GLOBAL.current_search = get_new_current_search();
function get_new_current_search() {
return {
stack:[],
search_options: {
keywords: ""
},
};
}
Then, I setup handlers for clicking different div sections in an accordion. This adds a new section to the accordion, makes it the currently viewed section, and sets up the click handlers for the next sections with the same function (setup_search_click_handlers).
function setup_search_click_handlers() {
$('.search_option').unbind("click");
$('.search_option').bind("click", function(e) {
var new_sub_group = $(this).attr('id');
$("#new_search_panel").bind("accordionchange", function(event, ui) {
$("#new_search_panel").unbind("accordionchange");
//push new section onto the current searches
INSIDE_GLOBAL.current_search.stack.push(new_sub_group);
/* pseudo code */
accordion_add_section_and_select_that_section( with_callback: setup_search_click_handlers );
});
$("#new_search_panel").accordion("activate",-1); //Collapse the accordion, calls the newly binded change
});
}
At the end of the first click, INSIDE_GLOBAL.current_search.stack has an element in it; However, when the next click event happens and the binded function called, INSIDE_GLOBAL.current_search.stack is back to being empty. Can't figure out why.
I'm assuming it has something todo with the scope of the different call backs, but really not sure.
In firebug, I can see the Window INSIDE_GLOBAL changing correctly, then being "reset" to where the stack array is empty again