jquery datatables using jumpToData() getting undefined error

jquery datatables using jumpToData() getting undefined error

longestdrivelongestdrive Posts: 9Questions: 5Answers: 0

I'm trying to use the page.jumpToData() api plugin with datatables v 1.10

I have included the script of the function within my page and have tried to use it like this:

$(document).ready(function() {   

var table = $('.datatable').dataTable();

table.page.jumpToData( "test", 0 );

});

I've omitted a number of settings for simplicity

The api script is:

jQuery.fn.dataTable.Api.register('page.jumpToData()', function (data, column) {
var pos = this.column(column, {order: 'current'}).data().indexOf(data);

if (pos >= 0) {
    var page = Math.floor(pos / this.page.info().length);
    this.page(page).draw(false);
}

return this;
});

I have tried placing within an InitComplete callback but no difference.

The error I get is:

Cannot read property 'jumpToData' of undefined 

Which I assume means the function does not exist? I'm not sure how to resolve. Does it fail if trying to extend the api if the datatable has not fully loaded?

Thank you

Answers

  • longestdrivelongestdrive Posts: 9Questions: 5Answers: 0

    I have found the problem for the undefined error.

    I have initiated using dataTable instead of DataTable. So I was trying to access the API from a Jquery object

    Having just upgraded hadn't recognised that part!

This discussion has been closed.