Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I use this to hook my scripts and styles to my plugin

add_action('admin_init', 'the_box_init' );

// Init plugin options to white list our options
function the_box_init(){
    register_setting( 'the_box_options', 'the_box', 'the_box_validate' );
    wp_enqueue_style( 'myprefix-style', plugins_url('theboxstyle.css', __FILE__) );
    wp_enqueue_script( 'myprefix-script', plugins_url('theboxjs.js', __FILE__) ); //this hook my custom js, preferrably which contents almost my jquery codes.

}

however, the jquery codes doesn't work even in this simple codes (refer below)

$( document ).ready(function() {
alert("asdasd");
}); 

and only javascript did work..

what does suppose my implementation get wrong that jquery didnt work?

im open in any suggestions, recommendations and idea's. Thank you in advance.

share|improve this question
    
your browser's javascript error console will likely tell you the problem, read the section titled jQuery noConflict Wrappers for wp_enqueue_script. also, admin_enqueue_scripts is the correct action to add admin scripts and styles. –  Milo Jan 18 at 20:13

1 Answer 1

up vote 1 down vote accepted

Check the DOM for the theboxjs.js and see if it is loaded correctly (check the output path). If not then you have path issues.

Try using admin_enqueue_scripts instead of admin_init for loading scripts.

You might also have conflict in your script. When writing scripts for WP try to avoid $ and use jQuery instead.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.