on click not working after upgrade from datatables 1.9.4 to 1.10.4

on click not working after upgrade from datatables 1.9.4 to 1.10.4

David GrigglestoneDavid Grigglestone Posts: 6Questions: 1Answers: 0

First post .. please bear with me!

I have a column definition in #mylist datatable thus:

            {
                // the export now button
                mData: "name",
                sClass: "text-center",
                bSearchable: false,
                bSortable: false,
                mRender: renderExportNowColumn
            }

with renderExportNowColumn defined as:

    function renderExportNowColumn(data, type, row) {
        return "<a class='btn btn-default btn-xs' data-toggle='tooltip' title='Export &quot;" +
            data +
            "&quot; now'><i class='fa fa-arrow-right'></i></a>";
    }

I have a handler defined thus:

    $('#mylist .btn').live('click', function() {

        var record = mytable.fnGetData($(this).parents('tr')[0]);
        alert(record.name);
    });

When upgrading to 1.10.4 I have changed the .live() to .on() but can no longer get the handler to fire. Any thoughts?

The table cells render just as they did with 1.9.4.

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    What was the change you make to your jQuery live function? You probably want something like:

    $('#mylist').on( 'click', 'tbody .btn', function () {
       ...
    } );
    

    Allan

  • David GrigglestoneDavid Grigglestone Posts: 6Questions: 1Answers: 0

    Doh! .. yup bad on() call .. thanks for quick response

This discussion has been closed.