I have a page with a div that is dynamically filled using a paginator ;-) At page init I load the first 10 forms in it using jquery .load() method.
What I\'d like to do
I'll try and address these one at a time to better match the question:
1) You can re-bind when you .load()
(or whatever jQuery ajax method you're using) or use a plugin like livequery(), for example here's re-binding (do this in your success
handler):
$("#myDynamicDiv .myForm").ajaxForm({ ...options... });
Or using livequery():
$(".myForm").livequery(function() { $(this).ajaxForm({ ...options... }); });
2) Use a class instead of IDs here, like this: class="myForm"
, whenever you want to handle batches of elements like this class
is a pretty safe route. The examples above work with class and not IDs per form (they can have IDs, they're just not used). Your form tags would look like this:
<form class="myForm">
3) The same solutions in answer #1 account for this :)
ID values are unique to a single DOM element. So you'd need to give each form a new ID, so if you had three forms, you could name them like so:
<form name="formone" id="formone"...
<form name="formtwo" id="formtwo"...
<form name="formthree" id="formthree"...
Now you'd create instances of your ajax request like so:
$('#formone, #formtwo, #formthree').ajaxForm({
beforeSubmit: showLoader,
success: hideLoader
});