draw/page events on datatables 1.10

draw/page events on datatables 1.10

RagingTrollRagingTroll Posts: 34Questions: 3Answers: 0
edited November 2013 in General
Hello, I've been playing around with the new 1.10 version, but i just can't seem to bind some code on the draw/page event like it used to work in the older versions.

This is what I've tried that doesn't work:
[code]$(dt.api().settings()[0].oInstance).on('draw', function () { // tried with 'page' as well..though i get some events working.. like 'sort'
alert('hello');
});[/code]

[code]dt.api().settings()[0].aoDrawCallback.push({
'fn': function () {
alert('hello');
},
'sName': 'hello'
});[/code]

[code]dt.on('draw', function () {
alert('hello');
});[/code]

None of these work. Is where some way to run code on these events from a plugin (not by passing it in the initialization by using fn)?
I need this so that I can add custom filter elements to the table.

Replies

  • allanallan Posts: 63,201Questions: 1Answers: 10,415 Site admin
    Is `dt` the result of `$().dataTable()` ? In which case use `dt.api().on( ... );` . The `on` method is a property of the new API, an instance of which can be obtained using `$().dataTable().api()` or `$().DataTable()` .

    This will all be int he documentation once its written!

    Allan
This discussion has been closed.