Trigger a row button programmaticaly on dblclick

Trigger a row button programmaticaly on dblclick

Nico1904Nico1904 Posts: 7Questions: 3Answers: 0
edited February 2020 in Free community support

Hello everyone,

I have created a table using datatable serverside.
In my columnDef, I define this columns :

{
                "render": function ( data, type, row ) {
                return '<a class="js-popin" href="{% url 'main:client_info' %}" data-popin-size="big" data-popin-type="card"><i class="c-fonticon__icon-plus"></i></a>'

                },
                "targets": 10,
                orderable:false,
            },

I can select a row by this way :

 $('#table_client tbody').on( 'dblclick', 'tr', function () {
        var id = table.row( table.$(this) ).data().id;
        alert( 'You clicked on '+id+'\'s row' );
       } );

What I would like to do is trigger the row button on double click on the corresponding row.
Is it something possible ?

Answers

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    By the "row button", do you mean the a element?

    $('a.js-popin', table.row().node()).click();
    

    Allan

  • Nico1904Nico1904 Posts: 7Questions: 3Answers: 0

    Exactly,
    Infurtunatly it don't work, it simulate a click on the first row and not on the a tag.
    I have added table.$(this) in $('a.js-popin', table.row(table.$(this)).node()).click() but it don't work too.

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.