From 00a99a0037e04f377a2805277aa7e83586cfe024 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Fri, 23 May 2014 16:30:53 +0100 Subject: [PATCH] Fix: IE8 events error * In IE8 if the DataTables width calculation functions were being triggered DataTables would clone the table node and then do a jQuery $().remove() on the cloned node. This was bad in IE8 as it meant that on the remove the events that were attached tot he original table were removed as well as the ones on the clone table. IE8 must retain some kind of link between the original and clone nodes. Using jQuery's clone() method resolves this. * See thread 21040 for more information --- .datatables-commit-sync | 2 +- examples/basic_init/zero_configuration.html | 12 ++++++++++-- media/js/jquery.dataTables.js | 19 +++++++++++++------ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.datatables-commit-sync b/.datatables-commit-sync index 3113c043..c807552e 100644 --- a/.datatables-commit-sync +++ b/.datatables-commit-sync @@ -1 +1 @@ -77ee28e07cf8b949f2650b800e0fca791d4b767f +b7feaa2d3aa296b3b0224af59f2523049eac63bb diff --git a/examples/basic_init/zero_configuration.html b/examples/basic_init/zero_configuration.html index 20434a1b..c6249967 100644 --- a/examples/basic_init/zero_configuration.html +++ b/examples/basic_init/zero_configuration.html @@ -20,7 +20,11 @@ $(document).ready(function() { - $('#example').dataTable(); + $('#example').dataTable( { + columnDefs: [ + { targets: 0, width: '50px' } + ] + } ); } ); @@ -535,7 +539,11 @@ $(document).ready(function() {

The Javascript shown below is used to initialise the table shown in this example:

$(document).ready(function() { - $('#example').dataTable(); + $('#example').dataTable( { + columnDefs: [ + { targets: 0, width: '50px' } + ] + } ); } );

In addition to the above code, the following Javascript library files are loaded for use in this diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 83734e5f..1ddcd9ba 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -2003,11 +2003,14 @@ settings.aiDisplay = settings.aiDisplayMaster.slice(); } + settings._drawHold = holdPosition; if ( holdPosition !== true ) { settings._iDisplayStart = 0; } _fnDraw( settings ); + + settings._drawHold = false; } @@ -3847,8 +3850,9 @@ /* Adjust the position of the header in case we loose the y-scrollbar */ divBody.scroll(); - /* If sorting or filtering has occurred, jump the scrolling back to the top */ - if ( settings.bSorted || settings.bFiltered ) { + // If sorting or filtering has occurred, jump the scrolling back to the top + // only if we aren't holding the position + if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) { divBodyEl.scrollTop = 0; } } @@ -3948,7 +3952,8 @@ // Otherwise construct a single row table with the widest node in the // data, assign any user defined widths, then insert it into the DOM and // allow the browser to do all the hard work of calculating table widths - var tmpTable = $( table.cloneNode( false ) ) + var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table + .empty() .css( 'visibility', 'hidden' ) .removeAttr( 'id' ) .append( $(oSettings.nTHead).clone( false ) ) @@ -4991,7 +4996,7 @@ * trigger * @memberof DataTable#oApi */ - function _fnCallbackFire( settings, callbackArr, event, args ) + function _fnCallbackFire( settings, callbackArr, e, args ) { var ret = []; @@ -5001,8 +5006,9 @@ } ); } - if ( event !== null ) { - $(settings.nTable).trigger( event+'.dt', args ); + if ( e !== null ) { + console.log( e+'.dt' ); + $(settings.nTable).trigger( e+'.dt', args ); } return ret; @@ -13971,6 +13977,7 @@ // on destroy, while the `dt` namespaced event is the one we are // listening for $(settings.nTable).on( 'order.dt.DT', function ( e, settings, sorting, columns ) { + console.log( 'doing an order' ); var colIdx = column.idx; cell