我正在使用chosen()实现我的下拉框。
在我的主页中,我设置了下拉框,代码如下
//Code in home template
.bookmark_questions
%select
%option{value: "xxxx"} xxxxxx
%option{value: "xxxx"} xxxxxx
%option{value: "xxxx"} xxxxxx
%option{value: "xxxx"} xxxxxx
//Code in home view
render: ->
$(@el).html @template()
@$('select').chosen()
@
在我的主视图中,我尝试激活通过“@$('select').chosen()
”选择的内容,但是当我尝试运行代码时,出现以下错误
this.search_field[0] is undefined
激活为我的案例选择的正确方法是什么?
最佳答案
我知道这已经很老了,但我遇到了几乎相同的问题,解决该问题的方法是等待调用插件,直到 select
附加到 DOM 之后
.
关于jquery - 如何为我的下拉框激活 selected(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10671692/