1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-02 14:24:11 +01:00

Fix #136 - Allow bDestroy / bRetrieve to have defaults set

- Typically I think setting bDestroy or bRetrieve as default true is a
  bad idea as it could lead to more processing of tables than is needed
  by mistake, but if set the defaults should be acted upon.

- These are slightly different to the other defaults since the settings
  object hasn't been expanded by the point they are checked, so need to
  manually check the values.
This commit is contained in:
Allan Jardine 2013-02-02 12:09:15 +00:00
parent 10a0d7bd04
commit b4aee323bd

View File

@ -1,3 +1,4 @@
/*global oInit,_that*/
var i=0, iLen, j, jLen, k, kLen; var i=0, iLen, j, jLen, k, kLen;
var sId = this.getAttribute( 'id' ); var sId = this.getAttribute( 'id' );
var bInitHandedOff = false; var bInitHandedOff = false;
@ -30,11 +31,14 @@ for ( i=0, iLen=DataTable.settings.length ; i<iLen ; i++ )
/* Base check on table node */ /* Base check on table node */
if ( DataTable.settings[i].nTable == this ) if ( DataTable.settings[i].nTable == this )
{ {
if ( oInitEmpty || oInit.bRetrieve ) var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : DataTable.defaults.bRetrieve;
var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : DataTable.defaults.bDestroy;
if ( oInitEmpty || bRetrieve )
{ {
return DataTable.settings[i].oInstance; return DataTable.settings[i].oInstance;
} }
else if ( oInit.bDestroy ) else if ( bDestroy )
{ {
DataTable.settings[i].oInstance.fnDestroy(); DataTable.settings[i].oInstance.fnDestroy();
break; break;