Make WordPress Core

Opened 16 years ago

Closed 16 years ago

#9881 closed defect (bug) (invalid)

Can't toggle the visibilty using jQuery anymore

Reported by: mcosx's profile mcosx Owned by: mcosx's profile mcosx
Milestone: Priority: normal
Severity: normal Version: 2.8
Component: JavaScript Keywords: reporter-feedback
Focuses: Cc:

Description

I was testing my plugin 'One Word A Day' in WP 2.8 and I cannot toggle the visibility of a div block anymore.

This is the jQuery code ( Line 96: http://svn.wp-plugins.org/one-word-a-day/trunk/classes/class.widget.php ) :

jQuery("#owad_post_settings").toggle("slow");

and this is the div block:

echo '<div id="owad_post_settings" style="';

if( ! $optionsowad_daily_post? )

echo 'display:none;';

echo '">';

some code with ending div tag

I even couldn't save the plugin options. I saw that there is a multiple widget support for plugins so can't I use my old code anymore? What goes wrong?

Attachments (2)

contact-form.zip (7.5 KB) - added by Denis-de-Bernardy 16 years ago.
one-word-a-day.zip (36.9 KB) - added by mcosx 16 years ago.

Download all attachments as: .zip

Change History (16)

#1 @Denis-de-Bernardy
16 years ago

  • Milestone changed from Unassigned to 2.8

Sounds like you're like me... in for a rewrite of all of your plugins that insert widgets. ;-)

#2 follow-up: @azaozz
16 years ago

Think there's an error in your selector, jQuery("input[name=owad_daily_post]") should be jQuery("input[name=\'owad_daily_post\']"). Some of this changed in jQuery 1.3.

#3 follow-up: @Denis-de-Bernardy
16 years ago

@andrew: the other issue is very real, though. If old-style widgets are supposed to work with the new API, the fact of the matter is they do not.

The attached plugin to convince you.

#4 in reply to: ↑ 2 @mcosx
16 years ago

Replying to azaozz:

Think there's an error in your selector, jQuery("input[name=owad_daily_post]") should be jQuery("input[name=\'owad_daily_post\']"). Some of this changed in jQuery 1.3.

The selector works. If I put "alert();" in the function body the alert window appears. But it appears twice! Using show() instead of toggle() doesn't change anything. I'll check the jQuery 1.3 API for that.

jQuery("input[name=owad_daily_post]").change(function () {

jQuery("#owad_post_settings").toggle("slow");
alert('This message appears so the selector is fine - arg karg');
});

});

The other problem is solved. The submit name changed from save-widgets to savewidget.

#5 in reply to: ↑ 3 @azaozz
16 years ago

Replying to Denis-de-Bernardy:

The attached plugin to convince you.

It seems that the $control_callback in wp_register_widget_control($id, $name, $control_callback, $options = array()) is not set properly in the attached plugin.

is_callable( $control_callback ) returns false.

#6 @Denis-de-Bernardy
16 years ago

it would return false when is_admin() returns false, yes, since the class is only around on the widgets.php page. but that shoudn't be an issue, should it?

#7 @Denis-de-Bernardy
16 years ago

Or then, maybe toss in a do_action("load-widgets.php"); call in admin-ajax.php where needed for backwards compat. I can't possibly be the only one who doesn't stick to loading admin functions when needed.

@mcosx
16 years ago

#8 @mcosx
16 years ago

@ azaozz: This was the first time using trac. Why are you the owner?

@ Whoever is able to: Can anyone split the posts related to Denis-de-Bernardy problem up? My problem is caused by jQuery.

I took a look in the jQuery 1.3 API and toggle() should be valid as I used it.

-> jQuery("#owad_post_settings").toggle("slow");

I've attached my plugin to this thread.

#9 @azaozz
16 years ago

The plugin throws errors on activation (php4). Tested this with other widgets and all seems to work properly.

#10 @azaozz
16 years ago

  • Keywords reporter-feedback added; jQuery WordPress plugin removed

#11 follow-up: @mcosx
16 years ago

  • Keywords reporter-feedback removed
  • Owner changed from azaozz to mcosx
  • Status changed from new to assigned

Please tell me what errors are thrown. PHP5 is available since four or five years :-/

#12 @mcosx
16 years ago

  • Keywords reporter-feedback added

Sorry for removing the tag. Added again.

#13 in reply to: ↑ 11 @azaozz
16 years ago

Replying to mcosx:

Please tell me what errors are thrown. PHP5 is available since four or five years :-/

The classes aren't initialized properly. WordPress supports php >= 4.3. If you don't want to support it in your plugin, perhaps do a version check at the beginning and show a warning, etc.

#14 @Denis-de-Bernardy
16 years ago

  • Milestone 2.8 deleted
  • Resolution set to invalid
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.