So I'm turning an "edit" form into an ajaxForm with the following:
$('#reviewForm').ajaxForm({
success: function (response) {
$('#bookReview').html(response);
}
});
This returns the same form, that can be edited again, if necessary. The second form submission, however, no longer has the ajaxForm() attached to it, which makes sense.
How do I make sure this form is always an ajaxForm, no matter how many submissions have taken place, similar to how the live() function works?
$('#myFormId').live('submit', function() {
// submit the form
$(this).ajaxSubmit();
// return false to prevent normal browser submit and page navigation
return false;
});
Sligtly modified example for ajaxSubmit from http://jquery.malsup.com/form/#api.
From the documentation :
delegation
true to enable support for event delegation requires jQuery v1.7+
// prepare all existing and future forms for ajax submission
$('form').ajaxForm({
delegation: true
});
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