I am using some existing code that has an form submit handler:
function AjaxFormSubmit(e) {
[...]
var form = $(this);
[...]
}
To bind the handler in my view code I have this:
$('myForm').submit(AjaxFormSubmit);
What I want to do is run some other code before calling AjaxFormSubmit with something like this:
$('myForm').submit(function(e) {
doSomething();
AjaxFormSubmit(e);
});
The problem is that in AjaxFormSubmit, the call to $(this) doesn’t get the form element. What is the best way to achieve this?
You need to be sure
thisgets called in the right context.