0

I'm trying to use wp_enqueue_script on my theme, to insert 3 javascript files on my page.

function mr_forms() {

            wp_register_script('validate-jquery',  get_bloginfo('template_url') . '/js/jquery.validate.min.js', array('jquery'),FALSE,TRUE);
            wp_enqueue_script('validate-jquery');
            wp_register_script('aditional-methods', get_bloginfo('template_url') . '/js/additional-methods.min.js', array('jquery','validate'),FALSE,TRUE);
            wp_enqueue_script('aditional-methods');
            wp_register_script('messages-ptbr', get_bloginfo('template_url') . '/js/messages_ptbr.js', array('jquery','validate'),FALSE,TRUE);
            wp_enqueue_script('messages-ptbr');
            wp_register_script('forms', get_bloginfo('template_url') . '/js/forms.js', array('jquery', 'maskedinput'), FALSE, TRUE);
            wp_enqueue_script('forms');
        }

        add_action('init', 'mr_forms');

But only the last javascript, "forms.js" is being inserted on my page, the others arent, does anyone know what might be happening ? and the other doesnt matter...

2
  • Can you confirm jQuery is being loaded? Commented May 17, 2011 at 13:32
  • It must be if forms.js is loading - I'm certain it'll be that validate is being required, rather than validate-jquery Commented May 17, 2011 at 13:38

1 Answer 1

1

Have you named validate incorrectly in the other register scripts? Should be validate-jquery instead of validate?

function mr_forms() {

        wp_register_script('validate-jquery',  get_bloginfo('template_url') . '/js/jquery.validate.min.js', array('jquery'),FALSE,TRUE);
        wp_enqueue_script('validate-jquery');
        wp_register_script('aditional-methods', get_bloginfo('template_url') . '/js/additional-methods.min.js', array('jquery','validate-jquery'),FALSE,TRUE);
        wp_enqueue_script('aditional-methods');

wp_register_script('messages-ptbr', get_bloginfo('template_url') . '/js/messages_ptbr.js', array('jquery','validate-jquery'),FALSE,TRUE);

        wp_enqueue_script('messages-ptbr');
        wp_register_script('forms', get_bloginfo('template_url') . '/js/forms.js', array('jquery', 'maskedinput'), FALSE, TRUE);
        wp_enqueue_script('forms');
    }

    add_action('init', 'mr_forms');
Sign up to request clarification or add additional context in comments.

2 Comments

thats not the problem..... I changed from "validate" to "validate-jquery" just to test if it was a name problem...... that's still not the problem but thx for trying... I can even remove the dependencies and it still doesn't load the files...
Are you looking in the footer, or in the head?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.