Selectize.js 在客户端使用 tornado wtforms 的搜索功能
Selectize.js search functionality on client side using tornado wtforms
我已经集成了 selctize.js 并在我的整个应用程序中使用它。无法找到搜索 select 中的值或文本的方法,因为有时可能会有大量选项。
我的 selectize.js
咖啡脚本
$('.select').selectize(
'plugins': ['remove_button'],
onDropdownOpen: ->
$('.sidebar_header').css 'z-index', '1'
$('.selectize-dropdown').mCustomScrollbar({
scrollInertia: '300'
})
return
onDropdownClose: ->
$('.sidebar_header').css 'z-index', '9999'
return
)
我的表格是由 python 生成的,选项是从后台给出的,通过放置在下面的模板中,我得到了包含所有选项的 select:
龙卷风重量形式:
class Form(BaseForm):
my_select = SelectPlusInitField(validators=[SelectRequired()])
tornado 处理程序准备 select:
form.my_select.choices = yield self.my_select_choices
龙卷风模板:
{{ form.my_select(class_='select') }}
为 select 生成的模板 html:
<select class="select selectized" id="my_select" name="my_select">
<option value="select" selected="selected">select</option>
<option value="1" selected="selected">1</option>
<option value="2" selected="selected">2</option>
</select>
// and below than selectize will generate his style for the above select
最终结果是从后端生成一个带有给定选项的select,我想在客户端添加没有后端的搜索功能,这可能吗?
最新版本selectize.js更新到最新版本后默认添加了搜索功能
我已经集成了 selctize.js 并在我的整个应用程序中使用它。无法找到搜索 select 中的值或文本的方法,因为有时可能会有大量选项。
我的 selectize.js
咖啡脚本 $('.select').selectize(
'plugins': ['remove_button'],
onDropdownOpen: ->
$('.sidebar_header').css 'z-index', '1'
$('.selectize-dropdown').mCustomScrollbar({
scrollInertia: '300'
})
return
onDropdownClose: ->
$('.sidebar_header').css 'z-index', '9999'
return
)
我的表格是由 python 生成的,选项是从后台给出的,通过放置在下面的模板中,我得到了包含所有选项的 select:
龙卷风重量形式:
class Form(BaseForm):
my_select = SelectPlusInitField(validators=[SelectRequired()])
tornado 处理程序准备 select:
form.my_select.choices = yield self.my_select_choices
龙卷风模板:
{{ form.my_select(class_='select') }}
为 select 生成的模板 html:
<select class="select selectized" id="my_select" name="my_select">
<option value="select" selected="selected">select</option>
<option value="1" selected="selected">1</option>
<option value="2" selected="selected">2</option>
</select>
// and below than selectize will generate his style for the above select
最终结果是从后端生成一个带有给定选项的select,我想在客户端添加没有后端的搜索功能,这可能吗?
最新版本selectize.js更新到最新版本后默认添加了搜索功能