0
我正在使用选定的jquery插件,并希望在调用change事件时立即触发打开的事件,以便显示包含所有选项的搜索栏。选择 - 在更改事件后触发打开事件
HTML代码
$(document).ready(function() {
$('#myselect').chosen().change(function(){
// alert('change event called');
$('#myselect').trigger('chosen:activate');
$('#myselect').trigger('chosen:open');
add_food({{profile_id}});
});
});
虽然$('#myselect').trigger('chosen:open');
打开了搜索栏和选项,当我试图在控制台上
<select id="myselect" data-placeholder="Add foods you can buy here." style="height:30px;width: 100%" class="chosen-select" >
<option value=""></option>
{% for each in food_list %}
<optgroup label={{each.node}}>
{% if each.children %}
{% for eachchild in each.children %}
<option>{{eachchild}}</option>
{% endfor %}
{% else %}
<option>{{each.node}}</option>
{% endif %}
</optgroup>
{% endfor %}
</select>