So this isn't specific to validate, but it seems to be the one that
for what ever reason causes me pain.

I usually try not to load the same javascript over and over so I do
something like this:

    if (typeof(writeLog) == 'undefined') {
                $.getScript("/javascript/mystuff/logger.js");
    }

This happens after I make sure jquery is loaded.

But when I do this with validate(???), it takes longer to load for
some reason and the next script starts loading and executing and I get
a bunch of undefined errors:

load jquery

<script type="text/javascript">
    if (typeof( $ ) == 'undefined') {
        var head = document.getElementsByTagName("head")[0];
        script = document.createElement('script');
        script.id = 'jquery-1.2.js';
        script.type = 'text/javascript';
        script.src = '/javascript/jquery/jquery-1.2.js';
        head.appendChild(script);
    }
</script>

<script type="text/javascript">
    if (typeof($.validator) == 'undefined')
        $.getScript(
                "/javascript/jquery/jquery.validate.js",
                function() { alert("jquery.validate script loaded and
executed."); }
        );
</script>

<script type="text/javascript">
        $.validator.setDefaults({ submitHandler: function()
{ alert("submitted!"); } });
.....


If I forget about checking if it is loaded and replace the check with
a direct script load:

<script src="/javascript/jquery/jquery.validate.js" type="text/
javascript"></script>

then everything is fine.


Anyone know what the best way to get around this issue?

thanks
dn

Reply via email to