Dropdown Semantic-UI: Change the hidden filed values?

夙愿已清 提交于 2019-12-11 08:16:32

问题


I am working with semantic-ui dropdown. I am wondering on how to change the values in hidden field based on user selection from the dropdown list ? Related Question may be!.

<div class="ui selection dropdown select-language">
    <input name="language" type="hidden" value="Alpha-Male">
    <div class="text">Gender</div>
    <i class="dropdown icon"></i>
    <div class="menu ui transition hidden">
        <div class="item" data-value="Alpha-Male">Male</div>
        <div class="item active" data-value="Alpha-Female">Female</div>
    </div>
</div>

回答1:


I checked out the source code of SemanticUI library and I found that the module functions are stored in data() using jQuery.

So, to access dropdown methods for your element you will do:

 $(".ui.selection").data().moduleDropdown

Change value is actually action.activate(text, value) function.

For example, to set Alpha-Female value you will do:

 $(".ui.selection")
   .data()
   .moduleDropdown
   .action
   .activate(undefined, "Alpha-Female")
 ;

JSFIDDLE



来源:https://stackoverflow.com/questions/22715193/dropdown-semantic-ui-change-the-hidden-filed-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!