1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-02-20 18:54:15 +01:00

Fix: fnOpen - when passed a TR element (or indeed any other element) that is not part of the master table (i.e. under control of DataTables), DatTables would try to "open" the row anyway - which was wrong. So now check that the node given is a TR element under control of DataTables, otherwise silently return. This is useful for using fnOpen when bound to all TR elements in the TBODY with a live event handler (i.e the click would also occur on the opened row).

This commit is contained in:
Allan Jardine 2012-01-15 10:09:06 +00:00
parent e1146e2f9d
commit 0c3dadbed9
2 changed files with 23 additions and 5 deletions

View File

@ -4482,7 +4482,7 @@
iColumn, iColumns, oData, sNodeName, iStart=0, iEnd=iRows;
/* Allow the collection to be limited to just one row */
if ( iIndividualRow )
if ( iIndividualRow !== undefined )
{
iStart = iIndividualRow;
iEnd = iIndividualRow+1;
@ -5503,7 +5503,9 @@
* @param {node} nTr The table row to 'open'
* @param {string|node|jQuery} mHtml The HTML to put into the row
* @param {string} sClass Class to give the new TD cell
* @returns {node} The row opened
* @returns {node} The row opened. Note that if the table row passed in as the
* first parameter, is not found in the table, this method will silently
* return.
*
* @example
* $(document).ready(function() {
@ -5526,6 +5528,13 @@
/* Find settings from table node */
var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
/* Check that the row given is in the table */
var nTableRows = _fnGetTrNodes( oSettings );
if ( $.inArray(nTr, nTableRows) === -1 )
{
return;
}
/* the old open one if there is one */
this.fnClose( nTr );

View File

@ -762,7 +762,9 @@ this.fnIsOpen = function( nTr )
* @param {node} nTr The table row to 'open'
* @param {string|node|jQuery} mHtml The HTML to put into the row
* @param {string} sClass Class to give the new TD cell
* @returns {node} The row opened
* @returns {node} The row opened. Note that if the table row passed in as the
* first parameter, is not found in the table, this method will silently
* return.
*
* @example
* $(document).ready(function() {
@ -785,6 +787,13 @@ this.fnOpen = function( nTr, mHtml, sClass )
/* Find settings from table node */
var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
/* Check that the row given is in the table */
var nTableRows = _fnGetTrNodes( oSettings );
if ( $.inArray(nTr, nTableRows) === -1 )
{
return;
}
/* the old open one if there is one */
this.fnClose( nTr );