mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-21 19: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:
parent
e1146e2f9d
commit
0c3dadbed9
13
media/js/jquery.dataTables.js
vendored
13
media/js/jquery.dataTables.js
vendored
@ -4482,7 +4482,7 @@
|
|||||||
iColumn, iColumns, oData, sNodeName, iStart=0, iEnd=iRows;
|
iColumn, iColumns, oData, sNodeName, iStart=0, iEnd=iRows;
|
||||||
|
|
||||||
/* Allow the collection to be limited to just one row */
|
/* Allow the collection to be limited to just one row */
|
||||||
if ( iIndividualRow )
|
if ( iIndividualRow !== undefined )
|
||||||
{
|
{
|
||||||
iStart = iIndividualRow;
|
iStart = iIndividualRow;
|
||||||
iEnd = iIndividualRow+1;
|
iEnd = iIndividualRow+1;
|
||||||
@ -5503,7 +5503,9 @@
|
|||||||
* @param {node} nTr The table row to 'open'
|
* @param {node} nTr The table row to 'open'
|
||||||
* @param {string|node|jQuery} mHtml The HTML to put into the row
|
* @param {string|node|jQuery} mHtml The HTML to put into the row
|
||||||
* @param {string} sClass Class to give the new TD cell
|
* @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
|
* @example
|
||||||
* $(document).ready(function() {
|
* $(document).ready(function() {
|
||||||
@ -5526,6 +5528,13 @@
|
|||||||
/* Find settings from table node */
|
/* Find settings from table node */
|
||||||
var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
|
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 */
|
/* the old open one if there is one */
|
||||||
this.fnClose( nTr );
|
this.fnClose( nTr );
|
||||||
|
|
||||||
|
@ -762,7 +762,9 @@ this.fnIsOpen = function( nTr )
|
|||||||
* @param {node} nTr The table row to 'open'
|
* @param {node} nTr The table row to 'open'
|
||||||
* @param {string|node|jQuery} mHtml The HTML to put into the row
|
* @param {string|node|jQuery} mHtml The HTML to put into the row
|
||||||
* @param {string} sClass Class to give the new TD cell
|
* @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
|
* @example
|
||||||
* $(document).ready(function() {
|
* $(document).ready(function() {
|
||||||
@ -785,6 +787,13 @@ this.fnOpen = function( nTr, mHtml, sClass )
|
|||||||
/* Find settings from table node */
|
/* Find settings from table node */
|
||||||
var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
|
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 */
|
/* the old open one if there is one */
|
||||||
this.fnClose( nTr );
|
this.fnClose( nTr );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user