I have a function that expects click event object as parameter. For example:
toggle: function (e) {
//does all the required work and then calls cancelEvent
this.cancelEvent(e);//IMPORTANT TO HANDLE LOCAL ANCHORS
},
cancelEvent:function(e) {
if (!e) e = window.event;
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}
},
I need to call toggle function on the page load.
I tried calling it without passing event parameter. However, doing so breaks the expected functionality and everything becomes un-editable.
Is there anyway I can get the current event object and pass it to the function?
Or should I attach load event too the event listener?
Please let me know what is the way out?