2
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by AshtonHogan
0

There's no straightforward way of knowing the order the functions will run. I would assume the last function to be appended will likely run last, but depending on how jQuery loops through the functions they could be called in reverse.

Even if you could predict the order of the functions, there's no built-in method for cancelling the loop (maybe try return false;, although I doubt it will do anything).

Your problem seems fairly trivial, why not instead call the second ready function inside your if statement within the first ready function?

Edited by mike_2000_17: Fixed formatting

0

There's no straightforward way of knowing the order the functions will run. I would assume the last function to be appended will likely run last, but depending on how jQuery loops through the functions they could be called in reverse.

Even if you could predict the order of the functions, there's no built-in method for cancelling the loop (maybe try return false;, although I doubt it will do anything).

Your problem seems fairly trivial, why not instead call the second ready function inside your if statement within the first ready function?

Edited by mike_2000_17: Fixed formatting

0

Good point, sorry about that...

You see, the first function is actually a validate:

$(document).ready(function() {
    $("#register_form").validate({
        rules: {
            username: {
                required: true,
                minlength: 3
            }
        },
        messages: {
            username: {
                required: "Please specify your name",
                minlength: "Your username should be at least 3 characters"
            }
        }

    });
});

Now I don't want to run the 2nd function (an ajax call to the back end, to check username availability) until the 1st function has no problems (there is input, and minlength is at least 2 chars).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.