Invalid operand to 'in': Object expected

Invalid operand to 'in': Object expected

R_GR_G Posts: 31Questions: 10Answers: 0

I'm upgrading various gems in my Ruby On Rails application to obtain some required support. However, I am getting a break related to DataTables for which I need support. The error thrown is as listed above, "Invalid operand to 'in': Object expected and this occurs in function isArraylike( obj ) on the line var length = "length" in obj && obj.length,.

The DataTables code provides this error:

The error:
---------------------------
Message from webpage
---------------------------
DataTables warning: table id=logstable - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3
---------------------------
OK   
---------------------------

My call, trying to comment out items until it worked which it never did:

    // Logs DataTable with sort on updated_at
    var logstable = $('#logstable').DataTable({ /*
        responsive: true,
        autoWidth: false,
        pagingType: 'full',
        jQueryUI: false,
        order: [[6, "desc"]] */
    });

It's call to $.fn. DataTable

  // With a capital `D` we return a DataTables API instance rather than a
  // jQuery object
  $.fn.DataTable = function ( opts ) {
    return $(this).dataTable( opts ).api();
  };

It's too hung for me to trace it further but it ends here with "Invalid operand to 'in': Object expected.
This occurs on the line: var length = "length" in obj && obj.length,

function isArraylike( obj ) {

  // Support: iOS 8.2 (not reproducible in simulator)
  // `in` check used to prevent JIT error (gh-2145)
  // hasOwn isn't used here due to false negatives
  // regarding Nodelist length in IE
  var length = "length" in obj && obj.length,
    type = jQuery.type( obj );

I will push it to an accessible page and send you more information on a private link. Allan, thanks for this code and all your support on it.

This question has an accepted answers - jump to answer

Answers

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

    Sounds like you need to update your DataTables to the current release which is 1.10.9.

    Allan

This discussion has been closed.