Wednesday, 3 August 2016

How do I add additional logic to a input (buttons) click event?

Sometimes you need to add additional logic to a existing buttons 'click' event. The code to add extra logic to the item (without overwriting the existing code) is as follows:

1. Store the elements click event in a variable

var clickEvent = $("input[id='MyButtonId']").click

2. Overwrite the existing 'click' function, but execute the saved clicked function.

$("input[id='MyButtonId']").on('click', function() {  eval(clickEvent); MyNewSaveMethod();} );

No comments:

Post a comment