Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#19102 closed defect (bug) (invalid)

Javascript execution in MU

Reported by: johncolvin's profile johncolvin Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2.1
Component: Multisite Keywords: reporter-feedback
Focuses: Cc:

Description

I've reproduced this issue on 4 separate MU installs. I'm trying to use a jQuery slider, but keep getting an undefined method error.

I'm enqueueing scripts according to the wordpress docs. I can see that the scripts are being loaded through the Chrome developer panel. When the method is called on an element, it produces a undefined method error. I can verify that the javascript that powers the slider is being run because I put alerts before and after it and saw both of those. If I run the slider method declaration from the console in the developer panel and then call the slider function on the element, everything works. So, it seems that the JS is running, but is then somehow being reset.

To confirm that this is an issue with MU, I can disable MU and just run my main site. When I do this, without changing any code, the slider works as expected.

I've tried enqueueing the scripts on a variety of actions including wp_head, init and template_redirect.

I've had this same javascript issue with all libraries I've tried to add. This issue can be reproduced easily with a single user instance of wordpress by installing the anything slider plugin, add some jQuery like:

jQuery(document).ready(function(){

jQuery('#slider').anythingSlider();

});

confirm that the slider works, go through the steps to enable MU. The slider should be broken after that.

Attachments (2)

front-page.php (1.9 KB) - added by johncolvin 13 years ago.
front-page.js (76 bytes) - added by johncolvin 13 years ago.

Download all attachments as: .zip

Change History (8)

#1 @scribu
13 years ago

  • Keywords reporter-feedback added

Please post a link to said jQuery slider script and also the exact error message.

@johncolvin
13 years ago

#2 @johncolvin
13 years ago

The error is:

Uncaught TypeError: Object [object Object] has no method 'anythingSlider'

The anything slider plugin is enqueuing all of its javascript files.

I'm enqueueing the javascript on my front page like this:

wp_enqueue_script('front-page', get_bloginfo('template_directory') . '/js/front-page.js', array('jquery'));
get_header();

This is the entire contents of front-page.js:

jQuery(document).ready(function(){
  jQuery('#slider').anythingSlider();
});

I've attached my front page template and the javascript enqueued on that page.

You can see the error in action here: https://upilot.asc.ohio-state.edu/

#3 @johncolvin
13 years ago

I've found what I believe to be another instance of this issue.

The create link button of the visual tiny MCE editor causes a javascript error when MU is enabled.

The exact error is

Uncaught TypeError: Object [object Object] has no method 'wpdialog'

The editor works as expected with MU disabled.

Last edited 13 years ago by johncolvin (previous) (diff)

#4 @scribu
13 years ago

I can't reproduce the TinyMCE error. Have you tried with a brand-new installation with no plugins and the twentyeleven theme?

#5 @johncolvin
13 years ago

My apologies - I've found the issue.

I have a custom plugin that was adding the google API jquery in a function called by the shutdown hook. So, the javascript execution error was entirely my fault.

I may still have found a bug in how MU and single user act. This issue went away in a single instance. So, it seems that MU is firing the shutdown hook differently than single user.

Once again, sorry for the false alarm.

#6 @scribu
13 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Ok, feel free to open a new ticket if you pinpoint the shutdown issue.

Note: See TracTickets for help on using tickets.