1.9 syntax still being used after upgrading to 1.10.x

1.9 syntax still being used after upgrading to 1.10.x

JohnEzlabJohnEzlab Posts: 17Questions: 4Answers: 0

I am using 1.10.7

I am trying to use deferRender with:

  $("#my_table").dataTable({
    ajax: $('#my_table').data('json-source'),
    deferRender: true,
    dataSrc: ""
  })

However I keep getting the error: "Uncaught TypeError: Cannot read property 'length' of undefined" from line 3315 of jquery.datatables.js, being the last line below:

// if there is an ajax source load the data
if ( dataSrc == 'ajax' ) {
  _fnBuildAjax( settings, [], function(json) {
    var aData = _fnAjaxDataSrc( settings, json );

    // Got the data - add it to the table
    for ( i=0 ; i<aData.length ; i++ ) {

when I look at the "settings" variable it lists:

bDeferLoading: false
sAjaxDataProp: "data"
sAjaxSource: null

I was surprised to see these columns and thought they would have had different values as I declared:

ajax: $('#my_table').data('json-source'),
deferRender: true,
dataSrc: ""

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,945Questions: 1Answers: 10,158 Site admin
    Answer ✓

    As the documentation for ajax.dataSrc shows, it is a child property of the ajax option. E.g. use:

    $("#my_table").dataTable({
      ajax: {
        url: $('#my_table').data('json-source'),
        dataSrc: ""
      },
      deferRender: true
    })
    

    The documentation also contains other similar examples.

    Allan

  • JohnEzlabJohnEzlab Posts: 17Questions: 4Answers: 0
    edited September 2015

    Thanks for the help Allan.

    Deleted my uneducated reply

This discussion has been closed.