stonecracker
7 Nov 2006, 7:38 PM
I found a mysterious behavior about onUpdate of UpdateManager: Fire multiple update event during on actual update action
The following is the code snippnet catch the bug, when bring out the context menu multiple times, there are N(number of previous update action) update event fired for any-single-context-menu-popout. The update event was remembered!
Is this is a bug or my mistake?
// initialize all
cm_init = function(e){
console.info("catched context menu onUpdate: %s, %.o",e, e)
// get links in the context menu
var cm_ajax_page = YAHOO.util.Dom.getElementsByClassName("ajax-panel", "a", "inquiryitem-context-menu");
// add callback for the links in the context menu
YAHOO.util.Event.addListener(cm_ajax_page, 'click', get_ajax_in_panel);
};
//fire a XHR call to get the context menu content as menu element
function call_context_menu(rowIndex, e){
var mgr = cm_div.getUpdateManager();
mgr.loadScripts = true;
id=grid.getSelectedRowId();
mgr.update('/inquiry/ajax/get_inquiryitem_action/'+id+'/');
//when context menu finshed loading, tigger initilization of the context menu links
mgr.onUpdate.subscribe(cm_init);
console.info("added onUpdate for context menu, %s, %.o", e, e);
};
// Add a listener of rightclick in the grid and calls out context menu
grid.addListener('rowcontextmenu', call_context_menu);
The following is the code snippnet catch the bug, when bring out the context menu multiple times, there are N(number of previous update action) update event fired for any-single-context-menu-popout. The update event was remembered!
Is this is a bug or my mistake?
// initialize all
cm_init = function(e){
console.info("catched context menu onUpdate: %s, %.o",e, e)
// get links in the context menu
var cm_ajax_page = YAHOO.util.Dom.getElementsByClassName("ajax-panel", "a", "inquiryitem-context-menu");
// add callback for the links in the context menu
YAHOO.util.Event.addListener(cm_ajax_page, 'click', get_ajax_in_panel);
};
//fire a XHR call to get the context menu content as menu element
function call_context_menu(rowIndex, e){
var mgr = cm_div.getUpdateManager();
mgr.loadScripts = true;
id=grid.getSelectedRowId();
mgr.update('/inquiry/ajax/get_inquiryitem_action/'+id+'/');
//when context menu finshed loading, tigger initilization of the context menu links
mgr.onUpdate.subscribe(cm_init);
console.info("added onUpdate for context menu, %s, %.o", e, e);
};
// Add a listener of rightclick in the grid and calls out context menu
grid.addListener('rowcontextmenu', call_context_menu);