From b87187fc5b7ecd540b699180b05a1db6cb8d425c Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Sun, 3 Mar 2013 12:03:44 +0000 Subject: [PATCH] Fix #162 - Flexible width is width="100%" is applied as attribute to the HTML table - Attach an event handler to the window to resize the table. Note that this isn't debounced - possibly it should be in future(?), but don't want to add the additional code required if it isn't required. It seems to function perfectly well for me! - Unbind needs to unbind by the instance unique reference since there might be multiple tables listening for the event. --- media/src/api/api.methods.js | 1 + media/src/core/core.sizing.js | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/media/src/api/api.methods.js b/media/src/api/api.methods.js index cfbcab4b..74e70275 100644 --- a/media/src/api/api.methods.js +++ b/media/src/api/api.methods.js @@ -494,6 +494,7 @@ this.fnDestroy = function ( bRemove ) /* Blitz all DT events */ $(oSettings.nTableWrapper).unbind('.DT').find('*').unbind('.DT'); + $(window).unbind('.DT-'+oSettings.sInstance); /* If there is an 'empty' indicator row, remove it */ $('tbody>tr>td.'+oSettings.oClasses.sRowEmpty, oSettings.nTable).parent().remove(); diff --git a/media/src/core/core.sizing.js b/media/src/core/core.sizing.js index 013a0f17..ceb1571b 100644 --- a/media/src/core/core.sizing.js +++ b/media/src/core/core.sizing.js @@ -249,6 +249,15 @@ function _fnCalculateColumnWidths ( oSettings ) if ( widthAttr ) { oSettings.nTable.style.width = _fnStringToCss( widthAttr ); + + if ( ! oSettings._attachedResizing && + (oSettings.oScroll.sY !== '' || oSettings.oScroll.sX !== '') ) + { + $(window).bind('resize.DT-'+oSettings.sInstance, function () { + _fnScrollDraw( oSettings ); + } ); + oSettings._attachedResizing = true; + } } }