BuddyPress Test Drive

  • Community
    • Activity
    • Groups
    • Members
  • News
  • About
  • Support
  • Profile picture of Tom

    Tom posted an update: 2 years, 0 months ago

    I can’t any of my custom jquery to work without calling googleapi jquery after WP_head. Do I remove jquery from bp and load it myself, or can I get the jquery that bp loads to do it by some special magic? Please help >_<

    • Profile picture of Tom
      Andrew Wayne replied 2 years, 0 months ago

      Andrew Wayne posted a new activity comment: %s @andy i would like to know this also..cant seem to get it to work

    • Profile picture of Tom
      Micha? M replied 2 years, 0 months ago

      Micha? M posted a new activity comment: %s use wp_enqueue_script() to load a script with dependencies.

      e.g. wp_register_script(’my-script-name’, plugins_url(’/plugin-name/js/my-script.js’), array(’jquery’));
      the last parameter is and array of script names that your script depends on.

      there’s a list of included script names along with full documentation here: http://codex.wordpress.org/Function_Reference/wp_enqueue_script

      also, jquery won’t always be available as ’$’ in wordpress. use ’jQuery’ or wrap your script in a function to set $ locally:

      (function($) {
      $(’a’).css(’color’, ’red’);
      })(jQuery);

      • Profile picture of Tom
        Tom replied 2 years, 0 months ago

        Tom posted a new activity comment: %s So if I use this then 1. I won’t have to activate jquery manually for my ”extra” jquery plugins and 2. I shouldn’t have a conflict with current jquery javascript that breaks things like the avatar cropper?

        • Profile picture of Tom
          Micha? M replied 2 years, 0 months ago

          @tmort
          1. yes. if you specify dependencies wordpress loads them automatically.
          2. yes. wordpress loads these libraries in a way that avoids conflicts.

          i just noticed i wrote wp_register_script instead of wp_enqueue_script.

          • Profile picture of Tom
            Tom replied 1 year, 12 months ago

            Finally got it to work, thank you so much for the help!

Proudly powered by WordPress and BuddyPress.

    • WordPress.org
    • Documentation
    • Support Forums
    • Feedback
  • Log in
  • Register