Reputation: 9037
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.
Upvotes: 0
Views: 38
Reputation: 38102
Try to put your code in a closure:
(function($){
alert("asdasd");
})(jQuery);
or:
$.noConflict();
jQuery(document).ready(function($) {
alert("asdasd");
});
This will helps you to prevent the conflict between Wordpress
and jQuery
Upvotes: 1