diff --git a/docs/_i18n/en/documentation/table-options.md b/docs/_i18n/en/documentation/table-options.md index 8833738920..3b1c109b77 100644 --- a/docs/_i18n/en/documentation/table-options.md +++ b/docs/_i18n/en/documentation/table-options.md @@ -524,6 +524,17 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`. false True to select checkbox or radiobox when clicking rows. + + ignoreClickToSelectOn + data-ignore-click-to-select-on + Function + { return $.inArray(element.tagName, ['A', 'BUTTON']); } + + Takes one parameters:
+ element: the element clicked on.
+ Return true if the click should be ignored, false if the click should cause the row to be selected. This option is only relevant if clickToSelect is true. + + singleSelect data-single-select diff --git a/src/bootstrap-table.js b/src/bootstrap-table.js index 77a51abff6..7e5c267edf 100644 --- a/src/bootstrap-table.js +++ b/src/bootstrap-table.js @@ -394,6 +394,10 @@ customSort: $.noop, + ignoreClickToSelectOn: function (element) { + return $.inArray(element.tagName, ['A', 'BUTTON']); + }, + rowStyle: function (row, index) { return {}; }, @@ -1911,7 +1915,7 @@ that.trigger(e.type === 'click' ? 'click-row' : 'dbl-click-row', item, $tr, field); // if click to select - then trigger the checkbox/radio click - if (e.type === 'click' && that.options.clickToSelect && column.clickToSelect) { + if (e.type === 'click' && that.options.clickToSelect && column.clickToSelect && that.options.ignoreClickToSelectOn(e.target)) { var $selectItem = $tr.find(sprintf('[name="%s"]', that.options.selectItemName)); if ($selectItem.length) { $selectItem[0].click(); // #144: .trigger('click') bug