Hello,
I need to submit a form from all the tab clicks . For that What I have done is by changing the tabs.js file in the following way
function decorateMenu(menu) {
var items = menu.getElementsByTagName("li");
for (var i=0; i < items.length; i++) {
items[i].firstChild.myIndex = i;
// retain any existing onclick handlers from menu-config.xml
xAddEvent(items[i].firstChild, 'click', formSumit);
setCookie("menuSelected", this.myIndex);
}
activateMenu(items);
}
function xAddEvent(element, event, fn){
//identify supported method of adding encapsulated event listeners
var etype = (typeof document.addEventListener != 'undefined') ? 'addEventListener' : (typeof document.attachEvent != 'undefined') ? 'attachEvent' : 'none';
//if encapsulated event listening is not supported, don't continue
if(etype == 'none') { return; }
//set event name prefix
eprefix = (etype == 'attachEvent' ? 'on' : '');
element[etype](eprefix + event, fn, false);
}
function formSumit(){
alert('going to submit form');
document.formTest.submit();
return false;
}
Here i have added an addevent method for adding a "formSubmit" method
One of the drawback with this approach is that I have hardcoded the name of the HTML form in this script. I was not able to parameterize the form name when called from the menu-config/jsp
I would like to know wheather there is any better approach compared to this ?