Implementation code of BootStrap select2 that can be queried and entered
- 2021-07-21 07:26:56
- OfStack
First of all, the key sentence:
$(".js-example-tags").select2({
tags: true
})
Don't underestimate the power of this code. Add class directly where you need it, as shown in the following code:
<div class="form-group required">
<label class="control-label col-sm-4"> Test select2: </label>
<div class="col-sm-8">
<form:select path="sett"
id="sett" class="form-control required js-example-tags"
onchange="onchange('${sett.costAmount}','${sett.id}');">
<form:option value='' label=' Please select ' />"
<form:options items="${fns:findSettList()}"
itemLabel="label" itemValue="value" htmlEscape="false" />
</form:select>
</div>
</div>
Note that the above code has an onchange method that needs to be
$(".js-example-tags").select2({
tags: true
})
Add to this method. Otherwise, it can't be realized.