I struck up in a Javascript method overriding problem for a while. the problem is i got onclick event handler on one of my controls and i need to to do inject some method before the event handler triggers the actual method.
assume DGrid.Headerclik is actuall assigned to onclick event.
And this is what i did
DGrid.Headerclik = handleinLocal;
so whenever user clicks the grid now the control comes to handleinLocal method. here i have to do some processing and then call the base Headerclik().
function handleinLocal(){
// here i need to call the DGrid.Headerclik() method (base)
}
but this is not working as expected. on calling the DGrid.Headerclik() within the handleinLocal() recursively calls the handleinLocal() method. But i need to call the base method...
is there a way to achieve theis in JavaScript??
You should store the previous handler in a (closure) variable:
(function() {
var oldHandler = DGrid.Headerclik;
DGrid.Headerclik = handleInLocal;
function handleInLocal() {
// ...
oldHandler();
// ...
}
})();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With