【发布时间】:2019-06-21 14:14:02
【问题描述】:
你能帮我用这个插件吗:
https://www.jqueryscript.net/form/Bootstrap-Combo-Box-Typeahead-Plugin-jQuery.html
我正在使用 Bootstrap 3,并且我已经将插件放在我的静态文件夹中。
我尝试在我的选择字段中添加一个 id,但没有成功。
forms.py
class IndividuForm(forms.Form):
individu = forms.ModelChoiceField(queryset=Individu.objects.order_by('nom'), empty_label="")
def __init__(self, *args, **kwargs):
super(IndividuForm, self).__init__(*args, **kwargs)
self.fields['individu'].widget.attrs={'class': 'combobox','id':'mySelect'}
脚本
<script>
$('.mySelect').combobox()
</script>
【问题讨论】:
标签: javascript jquery html django django-forms