[Solved] Sort event binding and v1.10.0-beta.3.dev

[Solved] Sort event binding and v1.10.0-beta.3.dev

Paul_FPaul_F Posts: 3Questions: 1Answers: 0
edited March 2014 in DataTables 1.10
Hi,

First of all, thank you Allan for this very usefull DataTables.

The "sort" event binding seem to be broken in the last nightly update (1.10.0-beta.3) as you can see here :
http://live.datatables.net/quwadex/1/edit
> .bind('sort', function() {alert("sort");})
Everything was fine using 1.9.4 version.

Regards,
Paul

Replies

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

    There is actually three things going on here... :-)

    1. `$('#example').DataTable()` returns a DataTables API instance, which doesn't have a `bind()` method. There are two options here - 1. simply change to use `dataTable()` (lowercase `D` ) which returns a jQuery object, or 2. Use the `on()` API method which is available in the DataTables API and works the same way as jQuery's.

    2. Events in DataTables 1.10 require the `.dt` namespace. This is because the custom events could otherwise conflict with events triggered by other plug-ins. This is unfortunately a breaking change, but there wasn't much option :-(.

    3. The `sort` event has been renamed `order` for consistency with the API and options in 1.10. I thought that with the events being so badly documented in 1.9- (i.e. only in the dev docs) that they would almost never be used, and so it would be an okay change to make. Perhaps not.....

    This is an update showing it working with `bind()` in 1.10:
    http://live.datatables.net/quwadex/2/edit

    Allan
  • Paul_FPaul_F Posts: 3Questions: 1Answers: 0
    Hi Allan,

    Thank you for this quick and efficient answer!
    It's working now.

    Paul
This discussion has been closed.