Make WordPress Core

Ticket #37973: 37973.2.diff

File 37973.2.diff, 1.7 KB (added by afercia, 8 years ago)
  • src/wp-admin/js/common.js

     
    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 );
     
    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 );
     
    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'),