语义UI下拉更改处理程序 [英] Semantic UI dropdown change handler
本文介绍了语义UI下拉更改处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Semantic UI我有下面的下拉菜单:
< div class =ui selection dropdown select-language> ;
< input name =languagetype =hiddenvalue =fr-FR>
< div class =text>法语< / div>
< i class =dropdown icon>< / i>
< div class =menu ui transition hidden>
< div class =itemdata-value =en-US>英语< / div>
< div class =item activedata-value =fr-FR>法语< / div>
< / div>
< / div>
在jQuery方面,我初始化了它:
$(。select-language)。dropdown()
如何添加更改
处理程序?
与此相关的唯一一件事我在文档是:
< blockquote>
onChange(value,text)
上下文:下拉菜单
在选择下拉项目后调用。收到选择的名称和值。
这听起来有点令我困惑。我如何使用它?
解决方案
实际上,有三种方法可以绑定事件:
//全局继承于init
$ .fn.dropdown.onChange = function(){...};
//初始化
$('。myDropdown')。dropdown({
onChange:function(){...}
});
//初始化后
$('。myDropdown')。dropdown('setting','onChange',function(){...});
I have the following dropdown using Semantic UI:
<div class="ui selection dropdown select-language">
<input name="language" type="hidden" value="fr-FR">
<div class="text">French</div>
<i class="dropdown icon"></i>
<div class="menu ui transition hidden">
<div class="item" data-value="en-US">English</div>
<div class="item active" data-value="fr-FR">French</div>
</div>
</div>
And in the jQuery side I init it:
$(".select-language").dropdown()
How can I add the change
handler?
The only thing related to this I found in the documentation is:
onChange(value, text)
Context: Dropdown
Is called after a dropdown item is selected. receives the name and value of selection.
This sounds a little confusing for me. How can I use it?
解决方案
Actually, there are three ways to bind the event:
// globally inherited on init
$.fn.dropdown.onChange = function(){...};
// during init
$('.myDropdown').dropdown({
onChange: function() {...}
});
// after init
$('.myDropdown').dropdown('setting', 'onChange', function(){...});
这篇关于语义UI下拉更改处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文