Is there a way to control the order in which functions are called, if using $(form).submit(function)?
If you call the following:
- $(form).submit(fun1);
- $(form).submit(fun2);
- $(form).submit(fun3);
it seems as though, when the form gets submitted, fun1 will get called first, followed by fun2, followed by fun3. My problem is, I'd like to call fun3 before I call fun2.
In practice, my situation is a little different. Here are the specifics. I'm using the
labelify plugin, which uses the label for a form element as the value of the form element. On form submit, if the value of the input is equal to the label, it clears the value. This would be fun1. I'm also using the validation plugin with a submitHandler, this would be fun2.
My form can grow dynamically as well, so if somebody clicks an "add" button, they get an additional set of inputs, and labelify is called on these additional inputs. As this happens after the form is already on the page, this is like adding fun3.
My symptom in this case is that form inputs that have been dynamically added don't have their default values from labelify removed, because the submitHandler (fun2) is called before labelify for any dynamically added inputs (fun3).