【发布时间】:2021-04-03 12:59:37
【问题描述】:
在 jquery datatable dom 中添加引导多选时遇到问题。我正在使用这个 example 在 jquery datatable 容器中添加自定义 dom 元素。它适用于普通的bootstrap select,但是当我尝试添加引导多选时,它无法按预期工作。你可以看下图。
这是我的工作代码
$(this).DataTable({
"language": (language == "de") ? DTlanguage : false,
"bSort": false,
lengthMenu: [
[25, 50, 100, 500, -1],
['25 ' + window.jsTranslations.rows + '', '50 ' + window.jsTranslations.rows + '', '100 ' + window.jsTranslations.rows + '', '500 ' + window.jsTranslations.rows + '', window.jsTranslations.show_all]
],
"dom": '<"toolbar">frtip', // this piece of code is responsible for adding multiselect
buttons: buttons,
});
$("div.toolbar").html(`
<select class="form-control multiselect document-templates" multiple="multiple" name="document_template[]">
</select> // this piece of code is responsible for adding multiselect
`);
【问题讨论】:
-
需要在渲染回调中进行
-
能否给个编码例子
-
这类作品 - 虽然我不确定你需要传递给
multiselect恐怕:jsfiddle.net/annoyingmouse/o7n86qjs
标签: javascript jquery bootstrap-4 datatables