Make WordPress Core

Changeset 38703


Ignore:
Timestamp:
10/03/2016 06:36:19 AM (10 years ago)
Author:
swissspidy
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/common.js

    r37714 r38703  
    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' );
     
    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() {
     
    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' ),
Note: See TracChangeset for help on using the changeset viewer.