WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#3343 closed defect (bug) (fixed)

Delete categories JavaScript error: Object doesn't support this property or method.

Reported by: dan-daemon Owned by: mdawaffe
Milestone: 2.1 Priority: normal
Severity: normal Version: 2.1
Component: Administration Keywords: has-patch needs-testing
Focuses: Cc:

Description (last modified by foolswisdom)

When I delete category, software initiates ajax request to the server, then delete item from the table by ajax response, correct? If so, after it I get JavaScript error: Object doesn't support this property or method.

I use IE7 and thought that this bug in JavaScript with new IE release, then I checked it to Firefox and got this JavaScript error after deleting category (copied from JavaScript console):

$(id) has no properties
http://my.domain.com/wp-includes/js/list-manipulation-js.php?ver=4187

Also, as I can see sometimes when I receive this error I also get this alert box (mostly Firefox):

Are you sure you want to navigate away from this page?
Slow down, I'm still sending your data[[br]]
Press OK to continue, or Cancel to stay on the current page.

This bug presents in IE all time, but in firefox only for first deleted item. Then I do not see any errors, deleting goes well.

Attachments (3)

3343.diff (14.0 KB) - added by mdawaffe 7 years ago.
3343b.diff (14.0 KB) - added by mdawaffe 7 years ago.
3343c.diff (14.0 KB) - added by mdawaffe 7 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 dan-daemon7 years ago

  • Milestone set to 2.1
  • Version set to 2.1

comment:2 foolswisdom7 years ago

  • Description modified (diff)
  • Summary changed from Add/Delete categories bug in last trunks to Delete categories JavaScript error: Object doesn't support this property or method.

Reproduced bug on delete of cat with IE 7

Hi Dan-daemon, thank you for reporting this problem. In the future please include the details right in the ticket.

ENV: WP trunk r4515

WinXP / IE 7

  • Could not reproduce on Linux / Firefox 2.0 - Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1) Gecko/20060601 Firefox/2.0 (Ubuntu-edgy)

Description was:
Hello guys,

Can you give me solution for bugs I described here:
http://wordpress.org/support/topic/93417?replies=2

Thanks,
Dan

comment:3 mdawaffe7 years ago

  • Owner changed from anonymous to mdawaffe
  • Status changed from new to assigned

I believe this is because most of WP's JS tries to use prototype's Element.x functions as extensions to the native JS element object like good little object oriented scripts.

But those extensions aren't reliable in all browsers. It's better to use Element.hide($('element_id'));, for example, than $('element_id').hide();

Patch

  1. Converts all WP core JS to use Element.method(el) rather than el.method();
  2. Fixes wp-ajax JS parser for IE 7.

mdawaffe7 years ago

comment:4 mdawaffe7 years ago

  • Keywords has-patch needs-testing added

I testing this and it all seems to work, but I'd appreciate other people trying it out in other browsers.

I was not able to test the changes to the cropper.

mdawaffe7 years ago

comment:5 mdawaffe7 years ago

3343b.diff

  1. First patch had a typo.

mdawaffe7 years ago

comment:6 mdawaffe7 years ago

3343c.diff

I think this is a better fix for WP's ajax response parser.

comment:7 ryan7 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [4768]) Category AJAX fixes from mdawaffe. fixes #3343

Note: See TracTickets for help on using tickets.