I have my own object with onShow() function, which is called (by me) when object is shown. I can override this function by assignment
o.onShow = function() { // something };
But it removes previous version of a function. So, if I wish to conserve existing handler, I should cache it and call in new handler:
o.oldOnShow = o.onShow;
o.onShow = function() { this.oldOnShow(); // something };
But this way I can cache only one previous handler. What if there are many of them?
Is there a convenient way to accomplish this task? How this task is named in literature? Is there a methods for this in jQuery?
In jQuery you can add as many handlers as you like:
$(o).on('show', function() { ... });
Subsequent calls won't remove previously-bound handlers.
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