您可以尝试以下方法来设置初始选择的项目:

  1. 将初始选择的项目添加到select元素的"selected"属性中:
<select name="keyModelList" multiple="multiple" size="10" class="form-control dual_select" required>
    <option th:each="dict : ${type}" th:text="${dict.modelNo}" th:value="${dict.modelNo}" selected></option>
</select>
  1. 通过JavaScript在初始化之后使用"bootstrapDualListbox"方法来设置初始选择的项目:
$('.dual_select').bootstrapDualListbox({
    // other options...
}).bootstrapDualListbox('setSelected', ['item1', 'item2', 'item3']);

请注意,您需要确保在初始化之后使用"bootstrapDualListbox"方法调用"setSelected"方法。

希望能帮到您


原文地址: http://www.cveoy.top/t/topic/i0BD 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录