javascript jQuery UI 多选小部件清除所有复选框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10633318/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery UI Multiselect widget clear all check boxes
提问by Declan McNulty
Hopefully a quick one...
希望快点...
I need to fire the uncheckAll event in the click event of a separate button on my page, I have tried the following:
我需要在页面上单独按钮的点击事件中触发 uncheckAll 事件,我尝试了以下操作:
$('.masterProviderOrgsListBox').multiselect().uncheckAll();
but this isnt a recognised method. I basically want to fire the same method that is fired when you click the "Uncheck All" box in the header.
但这不是公认的方法。我基本上想触发与单击标题中的“取消选中全部”框时触发的方法相同的方法。
I was previously doing this:
我以前是这样做的:
$('.masterProviderOrgsListBox option:selected').removeAttr("selected");
but this removes the selections on the actual multiselect rather than the jQuery UI widget.
但这会删除实际多选而不是 jQuery UI 小部件上的选择。
Couldnt find anything in the documentation, any ideas?
在文档中找不到任何内容,有什么想法吗?
回答by billyonecan
Methods
After an instance has been initialized, interact with it by calling any of these methods:
// example: $("#multiselect").multiselect("method_name");
方法
初始化实例后,通过调用以下任何方法与其交互:
// example: $("#multiselect").multiselect("method_name");
...which can be found in the widgets documentationunder Methods
...可以在方法下的小部件文档中找到
$("#multiselect").multiselect("uncheckAll");
回答by daudichya
1) first, you need to set default value of the control. jQuery('#multiselect').val("");
2) Then, execute below code to reset the control. jQuery('#multiselect').multiselect("refresh");
1)首先,您需要设置控件的默认值。jQuery('#multiselect').val("");
2) 然后,执行以下代码重置控件。jQuery('#multiselect').multiselect("refresh");
回答by user3796918
$("#multiselectoption:selected").removeAttr("selected");
$("#multiselect").multiselect('refresh');
refresh should be call after clearing the drop down.
清除下拉菜单后应调用刷新。