I had a similar problem when working heavily with Ajax and forms.
Initially, I was using the livequery plugin but because of performance
issues, I went with livequery. I'm not positive my example will work
with live.

Here's a quick example of one of three approaches that worked for me.

Encapsulate your validation in a function. (I somewhat mimicked your
code.) This function gets called when you click on the "Go" button
from the Ajax generated forms.

function submitEditsForm() {
        var v = $("#station_setup").validate({
                rules: {
                        edit_st_name: "required",
                        edit_un: "required",
                        edit_pass: "required"
                        // add more rules here
                },
                // submit form on validate
                submitHandler: function (form) {
                        var vars = $("#station_setup").serialize();
                        $.post("update_client.php", vars, function (data) {

                                // your success stuff
                                $('#new_client_setup').append('<p 
id="response">' + result + '</
p>');
                                $('#loading').fadeOut(500, function() {
                                        $(this).remove();
                                });
                                $('#client_list_holder ul').remove();
                                
$('#client_list_holder').load('client_list.php');

                        });
                }
        });
}

// bind "Go" button (referenced by id submitEdits)
// when this button gets clicked, the above function fires
$().ready(function() {
        $('#submitEdits').live('click',function() {
                submitEditsForm();
        });
});

Reply via email to