oTable in 1.9.4 has no fnIsOpen? "TypeError: Object [object Object] has no method 'fnIsOpen'"

oTable in 1.9.4 has no fnIsOpen? "TypeError: Object [object Object] has no method 'fnIsOpen'"

devgreerdevgreer Posts: 9Questions: 0Answers: 0
edited July 2013 in DataTables 1.9
I clipped some example code and stuck it into my dataTable like this:

[code]
"fnInitComplete": function(oSettings, json) {
jQuery('#data tbody tr').click( function () {
if ( oTable.fnIsOpen(this) ) {
oTable.fnClose( this );
} else {
oTable.fnOpen( this, "Temporary row opened", "info_row" );
}
} );
},
[/code]

Got this error "TypeError: Object [object Object] has no method 'fnIsOpen'".

Then I cut the snippet down to this, and it worked:

[code]
"fnInitComplete": function(oSettings, json) {
jQuery('#data tbody tr').click( function () {
oTable.fnOpen( this, "Temporary row opened", "info_row" );
} );
},
[/code]

Of course it doesn't close the opened row, though. Why is fnIsOpen not recognized here?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Try:

    [code]
    "fnInitComplete": function(oSettings, json) {
    var that = this;
    jQuery('#data tbody tr').click( function () {
    that.fnOpen( this, "Temporary row opened", "info_row" );
    } );
    },
    [/code]

    In fnInitComplete `this` should `=== oTable` - but it depends upon the rest of your code and what options you set. Using `this` is safer.

    Allan
  • devgreerdevgreer Posts: 9Questions: 0Answers: 0
    This doesn't work. And I got the snippet from this website, so you'd think it would work.
This discussion has been closed.