Get access to jquery object when using selector.DataTable()

Get access to jquery object when using selector.DataTable()

INTONEINTONE Posts: 153Questions: 58Answers: 6
edited July 2017 in DataTables 1.10

I am trying to trigger a deselect from within another handler but I cannot get access to jquery object.

campaignRewardTable = $('#campaignReward').DataTable({...});
campaignRewardTable.on( 'deselect', function () {...});
getMerchants().success(function (data) {
   campaignRewardTable.ajax.reload( null, false );
   campaignRewardTable.trigger('deselect'); //Uncaught TypeError: campaignRewardTable.trigger is not a function
});

Any help is appreciated.

Answers

  • INTONEINTONE Posts: 153Questions: 58Answers: 6
    edited July 2017

    Seems I cannot call a trigger on campaignRewardTable because it was not created by native jquery.

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

    Two options:

    1. table().table() to get the table element and then use $() on it
    2. Do something like:
    var jqTable = $('#campaignReward');
    campaignRewardTable = jqTable.DataTable({...});
    campaignRewardTable.on( 'deselect', function () {...});
    getMerchants().success(function (data) {
       campaignRewardTable.ajax.reload( null, false );
       jqTable.trigger('deselect');
    });
    

    Allan

This discussion has been closed.