Mike...

I tried both $form and $(form) and neither of them worked.

I will give your code a try though.

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Mike Alsup
Sent: Monday, August 27, 2007 10:39 AM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: $(this) after using ajaxForm from the Form plugin?


Andy,

Are you sure you used $form?   I see this is what you have commented out:

// $(form).before(data.split('!!!')[1]);

That should work if you call it like this:

$form.before(data.split('!!!')[1]);

Note the use of $form instead of $(form).

Based on what you've got in your workaround, this is how I would code it
using ajaxForm:

$('.commentForm form').ajaxForm({
    clearForm: true,
    beforeSubmit: function(arr, $form, opts) {
        var vals =
$form.find('[EMAIL PROTECTED],[EMAIL PROTECTED]').fieldValue();
        if (!vals[0] || !vals[1]) {
            alert('Both name and comment are required');
            return false;
        }
    },
    success: function(data, status, $form) {
        $form.parent().before(data).prev('.singleComment').slideDown();
    }
});

Mike


On 8/27/07, Andy Matthews <[EMAIL PROTECTED]> wrote:
>
> Yep...
>
> You're welcome to take a look at my final code.
>


Reply via email to