2

I am using Events Manager Plugin

Javascript is not working on Submit Events Page . I found the reason behind this , that was, I have written a line of code in functions.php to call jquery file.

wp_enqueue_script('jquery-1.7.2',get_template_directory_uri().'/js/jquery-1.7.2.min.js');

When I remove this line of code then javascripts start working fine on Event Submission Page but this file is important for me because I am using this file at many places too so I can not remove this. For Example I have a line of code which generates error.Line is :

var p_option = $('input[@name="p_option"]:checked').val(); .

This line is written in 'wordpress_1/wp-content/themes/my-theme/sidebar.php'

I also asked this question on plugin support but no reply from there.

Thanks in advance!!!

  • 3
    You're enqueuing a specific version of jquery. It's better to enqueue the version that comes with WP, like this: wp_enqueue_script('jquery'); in a function run by the hook wp_enqueue_scripts – Lea Cohen Jan 29 '13 at 13:09
  • @LeaCohen, I think this could go straight as an Answer... ;) – brasofilo Jan 29 '13 at 13:18
  • @LeaCohen When I am using wp_enqueue_script('jquery'); then it is showing error $ is not a function means javascript is not working. Let me tell you I am writing this in my custom theme's function.php file – Bhuvnesh Gupta Jan 30 '13 at 5:22
  • 2
    @BhuvneshGupta - WordPress jQuery is in noConflict mode, you must use jQuery as object reference, not $. – Milo Jan 30 '13 at 5:39
  • 1
    jQuery, not jquery. please read the page I linked above carefully. update your question with your current code. – Milo Jan 30 '13 at 6:29
2

You're enqueuing a specific version of jQuery. It's better to enqueue the version that comes with WP, like this: wp_enqueue_script('jquery'); in a function run by the hook wp_enqueue_scripts

  • When I am using wp_enqueue_script('jquery'); ** then it is showing error **$ is not a function means javascript is not working. Let me tell you I am writing this in my custom theme's function.php file so is it right way to add jquery file. – Bhuvnesh Gupta Jan 30 '13 at 5:24
  • @BhuvneshGupta, As written in the codex, and as Milo said in one of the comments to your question, WP runs jQuery in no-conflict mode, which means that the $ shortcut is not available and the longer jQuery is used. I suggest you read a little about it int the codex, in the link I gave. – Lea Cohen Jan 30 '13 at 6:10
  • I did it. I tried jquery too but not working. Please read our comments conversation. – Bhuvnesh Gupta Jan 30 '13 at 6:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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