From fd5d2a65ade9ebedd47a6002c91c82194fac007e Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 3 Oct 2016 06:36:19 +0000 Subject: [PATCH] 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 --- src/wp-admin/js/common.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/js/common.js b/src/wp-admin/js/common.js index 200d3e4780..d4caaff4ce 100644 --- a/src/wp-admin/js/common.js +++ b/src/wp-admin/js/common.js @@ -426,10 +426,11 @@ $document.ready( function() { // Init screen meta screenMeta.init(); - // check all checkboxes - $('tbody').children().children('.check-column').find(':checkbox').click( function(e) { - if ( 'undefined' == e.shiftKey ) { return true; } - if ( e.shiftKey ) { + // This event needs to be delegated. Ticket #37973. + $body.on( 'click', 'tbody .check-column :checkbox', function( even ) { + // Shift click to select a range of checkboxes. + if ( 'undefined' == event.shiftKey ) { return true; } + if ( event.shiftKey ) { if ( !lastClicked ) { return true; } checks = $( lastClicked ).closest( 'form' ).find( ':checkbox' ).filter( ':visible:enabled' ); first = checks.index( lastClicked ); @@ -447,7 +448,7 @@ $document.ready( function() { } lastClicked = this; - // toggle "check all" checkboxes + // Toggle the "Select all" checkboxes depending if the other ones are all checked or not. var unchecked = $(this).closest('tbody').find(':checkbox').filter(':visible:enabled').not(':checked'); $(this).closest('table').children('thead, tfoot').find(':checkbox').prop('checked', function() { return ( 0 === unchecked.length ); @@ -456,7 +457,8 @@ $document.ready( function() { return true; }); - $('thead, tfoot').find('.check-column :checkbox').on( 'click.wp-toggle-checkboxes', function( event ) { + // This event needs to be delegated. Ticket #37973. + $body.on( 'click.wp-toggle-checkboxes', 'thead .check-column :checkbox, tfoot .check-column :checkbox', function( event ) { var $this = $(this), $table = $this.closest( 'table' ), controlChecked = $this.prop('checked'),