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,TR开发者_开发问答UE);
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...
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');
精彩评论