Button in dataTable column stopped working

Button in dataTable column stopped working

sibapssibaps Posts: 1Questions: 1Answers: 0

Link to test case:

<script>
    var table = $('#scrip-data').DataTable({
        dom: 'Bfrtip',
        searching: false,
        paging: false,
        info: false,
        "serverSide": true,
            ajax: {
                url: "getDashboardData",
                type: "GET",
            },
            data: Response.data,
            contentType: "application/json",
            dataType: 'json',
            columns: [
                {data: "SCRIP"},
                {data: "LTP"},
                {data: "CAMARILLA","render": function(data, type, full, meta){
                        if (data == 'Buy' & "TRIGGER PRICE"!="NULL"){
                            //window.alert(data["SCRIP"]);
                            return '<kite-button class="kite-trade-button kite-buy" data-kite="kitedemo" data-exchange="NSE" data-tradingsymbol="' + full["SCRIP"] + '"data-transaction_type="Buy" data-quantity="100" data-order_type="LIMIT" data-price="100">   </button>';
                            //console.log(data);
                        }else if(data == 'Short') {
                            return '<kite-button class="kite-trade-button kite-sell" data-kite="kitedemo" data-exchange="NSE" data-tradingsymbol="' + full["SCRIP"] + '"data-transaction_type="Sell" data-quantity="100" data-order_type="LIMIT" data-price="100">   </button>';

                        }
                    }
                },
                {data: "ALERT"},
                {data: "PROFIT"},
                {data: "updatedAt","render": function(data){
                    var d = new Date(data).toLocaleTimeString()
                    return d
                }
            },
            ],

        });

        setInterval( function () {

            table.clear();
            table.draw();
            table.ajax.reload();
        }, 20000);
</script>

Description of problem:
I am using ajax to reload dataTable every 30sec. But when I load my page for the first time or refresh(F5) buttons in column works but while datatable reload happens after 30sec ,buttons stops working. Need some guidance here.

Answers

Sign In or Register to comment.