Skip to content Skip to sidebar Skip to footer

Handling Multiple Forms In The Same Page

If I have something like this in some page in my project:

Solution 1:

Whenever you are uncertain about access to elements within a plugin you can always initialize them individiually within an each loop.

Within eachthis will be the element instance and you can store it as variable to pass into plugin.

$('form.form').each(function () {
    /* assign "this" to variable that can be used inside plugin */var form = this;
    $(form).ajaxForm(function (data) {
        if (data == '') {
            $('#yes').css('display', 'block');
        } else {
            $('#not').css('display', 'block');
        }
        form.reset();
    });
});

Post a Comment for "Handling Multiple Forms In The Same Page"