_fnSettingsFromNode issue

_fnSettingsFromNode issue

alexwilliamsalexwilliams Posts: 1Questions: 0Answers: 0

It is possible the code base I'm working on has its own subtle issues. However, I've noticed that the line
var idx = $.inArray(table, _pluck(_pluck(settings, 'nTable')); in _fnSettingsFromNode
fails and returns -1 sometimes. The following alteration fixes the issue:

    function _fnSettingsFromNode ( table )
    {
        var settings = DataTable.settings;
        var idx = $.inArray(table.id, _pluck(_pluck(settings, 'nTable'), 'id')); /* change */
    
        return idx !== -1 ?
            settings[ idx ] :
            null;
    }

It's likely that the table isn't properly in the DOM when we call fnSettingsFromNode since we use jQuery.fn.detach to unload components that aren't being displayed. I'm not sure if it's appropriate to take that into account in the dataTables library, but the solution above seems to work if it is.

This discussion has been closed.