Prevent browser default on header right-click
Hi,
http://foxincloud.com/tutotest/wFormStandardPage.tuto?awForm=pagedGrid.scx implements grid.onHeaderClicked():
We try to prevent the browser context menu to appear by:
works on some browsers, and not on some others; eg:
Firefox PC OK
Firefox Mac KO
This code solves the problem on Firefox Mac:
QUESTION:
How can I get the 'aw36-header-2-box-text' id automatically?
eg
Thanks,
http://foxincloud.com/tutotest/wFormStandardPage.tuto?awForm=pagedGrid.scx implements grid.onHeaderClicked():
oGrid.onHeaderClicked = function(event, col){
event.cancelBubble = true;
event = Event.extend(event); // http://api.prototypejs.org/dom/Event/extend/
if(event.isLeftClick()){
col = parseInt(col, 10);
var result, dynCC;
if (typeof row !== 'undefined') {
row = parseInt(row, 10);
dynCC = this.getCellCurrentControl(col,row);
}
switch (col){
case 00: result = FoxInCloud.gridHeaderClicked(event, $('pagedgrid_scx-awgrd1-awgrd1'), 'pagedgrid_scx-awgrd1-awgrd1-column1-header1');break;
case 01: result = FoxInCloud.gridHeaderClicked(event, $('pagedgrid_scx-awgrd1-awgrd1'), 'pagedgrid_scx-awgrd1-awgrd1-column2-header1');break;
case 02: result = FoxInCloud.gridHeaderClicked(event, $('pagedgrid_scx-awgrd1-awgrd1'), 'pagedgrid_scx-awgrd1-awgrd1-column3-header1');break;
}
return result;
}
if(event.isRightClick()){ // http://api.prototypejs.org/dom/Event/isRightClick/
event.preventDefault(); // HERE
col = parseInt(col, 10);
var result, dynCC;
if (typeof row !== 'undefined') {
row = parseInt(row, 10);
dynCC = this.getCellCurrentControl(col,row);
}
switch (col){
case 00: result = FoxInCloud.gridHeaderClicked(event, $('pagedgrid_scx-awgrd1-awgrd1'), 'pagedgrid_scx-awgrd1-awgrd1-column1-header1');break;
case 01: result = FoxInCloud.gridHeaderClicked(event, $('pagedgrid_scx-awgrd1-awgrd1'), 'pagedgrid_scx-awgrd1-awgrd1-column2-header1');break;
case 02: result = FoxInCloud.gridHeaderClicked(event, $('pagedgrid_scx-awgrd1-awgrd1'), 'pagedgrid_scx-awgrd1-awgrd1-column3-header1');break;
}
return result;
}
};
We try to prevent the browser context menu to appear by:
event.preventDefault(); // HERE
works on some browsers, and not on some others; eg:
Firefox PC OK
Firefox Mac KO
This code solves the problem on Firefox Mac:
$('aw36-header-2-box-text').observe('contextmenu', function(event){event.preventDefault()})
QUESTION:
How can I get the 'aw36-header-2-box-text' id automatically?
eg
var headerID = oGrid.getHeaderID(col); // does this method exist?
$(headerID).observe('contextmenu', function(event){event.preventDefault()});
Thanks,
Thierry Nivelet (http://FoxInCloud.com/)
December 11,