Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit b87187fc5b7ecd540b699180b05a1db6cb8d425c 1 parent 25eaa86
@DataTables authored
Showing with 10 additions and 0 deletions.
  1. +1 −0  media/src/api/api.methods.js
  2. +9 −0 media/src/core/core.sizing.js
View
1  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();
View
9 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;
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.