Bug in Constructor + fix

Bug in Constructor + fix

motmot Posts: 5Questions: 0Answers: 0
edited April 2010 in Bug reports
Imagine this situation - you have ajax-powered site.
You use tabs to show different pages. Tab content is loaded by ajax in the same div (jqueryui tabs or jquery tools tabs behaviour).
In one tab you have DataTables. You set #id for DataTables table.
So, what will happen when we show page with DataTables, then another, then first page with DataTables again.
We will have 2 table configs in _aoSettings with the same sInstance property BUT with different nTable properties. Actually first nTable will point to non-existing table.
And table functions will stop working.

Quick way to fix this - add these lines after line #4911 (version 1.6.2):
[code]
if ( _aoSettings[i].sInstance == this.getAttribute( 'id' ) ) {
_aoSettings.splice(i, 1);
break;
}
[/code]
Code is self-explanatory - if we have table with such #id in _aoSettings - delete it.

Side effect - if we have two different tables with the same #id on one page and we init both - we will 'lose' first table.
This discussion has been closed.