Skip to content

Commit fd5d2a6

Browse files
committed
Plugins: Fix checkbox selection when searching for installed plugins.
Since the plugin search works via Ajax, the JavaScript events need to delegated in order for the checkboxes to work properly. Props afercia. Fixes #37973. git-svn-id: https://develop.svn.wordpress.org/trunk@38703 602fd350-edb4-49c9-b593-d223f7449a82
1 parent a39953e commit fd5d2a6

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/wp-admin/js/common.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,11 @@ $document.ready( function() {
426426
// Init screen meta
427427
screenMeta.init();
428428

429-
// check all checkboxes
430-
$('tbody').children().children('.check-column').find(':checkbox').click( function(e) {
431-
if ( 'undefined' == e.shiftKey ) { return true; }
432-
if ( e.shiftKey ) {
429+
// This event needs to be delegated. Ticket #37973.
430+
$body.on( 'click', 'tbody .check-column :checkbox', function( even ) {
431+
// Shift click to select a range of checkboxes.
432+
if ( 'undefined' == event.shiftKey ) { return true; }
433+
if ( event.shiftKey ) {
433434
if ( !lastClicked ) { return true; }
434435
checks = $( lastClicked ).closest( 'form' ).find( ':checkbox' ).filter( ':visible:enabled' );
435436
first = checks.index( lastClicked );
@@ -447,7 +448,7 @@ $document.ready( function() {
447448
}
448449
lastClicked = this;
449450

450-
// toggle "check all" checkboxes
451+
// Toggle the "Select all" checkboxes depending if the other ones are all checked or not.
451452
var unchecked = $(this).closest('tbody').find(':checkbox').filter(':visible:enabled').not(':checked');
452453
$(this).closest('table').children('thead, tfoot').find(':checkbox').prop('checked', function() {
453454
return ( 0 === unchecked.length );
@@ -456,7 +457,8 @@ $document.ready( function() {
456457
return true;
457458
});
458459

459-
$('thead, tfoot').find('.check-column :checkbox').on( 'click.wp-toggle-checkboxes', function( event ) {
460+
// This event needs to be delegated. Ticket #37973.
461+
$body.on( 'click.wp-toggle-checkboxes', 'thead .check-column :checkbox, tfoot .check-column :checkbox', function( event ) {
460462
var $this = $(this),
461463
$table = $this.closest( 'table' ),
462464
controlChecked = $this.prop('checked'),

0 commit comments

Comments
 (0)