Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap table - cannot add click event on tr

I'm using Bootstrap table (http://wenzhixin.net.cn/p/bootstrap-table/docs/index.html)

I'm trying to add click event

$('tr').click(function(){ console.log('test'); });

but it doesn't work. I know that there is event in bootstrap-table library, but it's important for me to use it exactly with jQuery's .click. Do you know what is blocking this event in bootstrap-table source code? I tryied to remove all ".off"s from bootstrap-table.js, but it didn't help.

like image 535
user3550394 Avatar asked Oct 25 '14 22:10

user3550394


1 Answers

I think you can use the onClickRow or click-row.bs.table event instead of the tr click event, here is the documentation and examples.

Code example:

// Fires when user click a row
$('#table').bootstrapTable({
    onClickRow: function (row, $element) {
        // row: the record corresponding to the clicked row, 
        // $element: the tr element.
    }
});

// or
$('#table').on('click-row.bs.table', function (e, row, $element) {
    // console.log(row, $element);
});

(I am the author of Bootstrap Table, hope to help you!)

like image 150
wenyi Avatar answered Sep 18 '22 12:09

wenyi