Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#28702 closed enhancement (wontfix)

using jQuery.on binding for catching the click in custom-header.js

Reported by: DaanMeijer Owned by:
Priority: normal Milestone:
Component: Customize Version: 4.0
Severity: normal Keywords: has-patch close
Cc: Focuses:

Description

I ran into this while building a theme that allows for images in it's custom widgets. The problem:

I want to use wp-admin/js/custom-header.js to bind to my
<a id="choose-from-library-link"> ... </a> ,
but because a widget form is loaded through AJAX, the element does not exist in the DOM yet, when the click is caught.

I propose changing line 18 of wp-admin/js/custom-header.js to
$(document).on('click', '#choose-from-library-link', function( event ) { .

Attachments (1)

28702.patch​ (465 bytes ) - added by chriseverson 12 years ago.

Download all attachments as: .zip

Change History (5)

#1 @SergeyBiryukov
12 years ago

  • Component Administration → Customize
  • Keywords needs-patch added
  • Milestone Awaiting Review → Future Release

@chriseverson
12 years ago

#2 @chriseverson
12 years ago

  • Keywords has-patch added; needs-patch removed

#3 @celloexpressions
12 years ago

  • Keywords close added

I don't see a problem with making this change per se, but I would not recommend using an admin-specific file that's liable to change and, in this case, possibly even be removed (see #25571), in a theme or plugin. And this change isn't necessary for this file to function as intended for core.

If you want similar functionality to what that file does, copy it into a new, appropriately named file bundled with your theme/plugin and tweak it to fit your needs. Or, look at a tutorial on using the media library in themes and plugins. Also, you shouldn't use an id like that in a widget, as multiple instances of the widget will result in duplicate ids.

#4 @celloexpressions
12 years ago

  • Milestone Future Release
  • Resolution → wontfix
  • Status new → closed

Per previous comment, this isn't really needed for core and facilitates invalid use of this file.

Note: See TracTickets for help on using tickets.