[wp-trac] [WordPress Trac] #16655: Media Library assign popup capturing incorrect checked radio elements
WordPress Trac
wp-trac at lists.automattic.com
Fri Feb 25 02:33:22 UTC 2011
#16655: Media Library assign popup capturing incorrect checked radio elements
--------------------------+-----------------------------
Reporter: pmenard | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.1
Severity: normal | Keywords:
--------------------------+-----------------------------
Been researching a bug which is effecting my plugin, Media-Tags. Please
don't stop reading there. This is not a support question.
When on the Media > Library page and you click 'Attach' link on any
unassigned row. You get the search popup titled 'Find Posts or Pages'. You
fill in something for the search input. Select the 'Posts' or 'Pages'
radio buttons.
Here is the defect:
In wp-admin/includes/js/media.js (line 34 of media.dev.js)
$("input[@name='itemSelect[]']:checked").each(function() { selectedItem =
$(this).val() });
This above code loops through every single checked input on the page.
Meaning the code finds in order the following checked input fields:
author, parent, comments, date then either post or page from the assign
popup.
This is wrong in that it is inefficient. Mainly because the 'itemSelect[]'
does nothing. But also just by chance it ends at the last checked input
field. The problem is when a plugin adds other radio input fields then
those are picked up instead of the value of the selected radio on the
popup.
The code should be changed to limit the jQuery code to the input radios
within popup like
$("input[@name='find-posts-what[]']:checked").each(function() {
selectedItem = $(this).val() });
The 'find-post-what' in the selector is obvious since the Posts or Pages
form radios are in that group.
This is being reports for WP 3.1 but goes back to previous versions.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16655>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list