Javascript jQuery Multiselect-选择所有事件处理程序

Javascript jQuery Multiselect-选择所有事件处理程序,javascript,jquery,multi-select,jquery-multiselect,Javascript,Jquery,Multi Select,Jquery Multiselect,我有一个jquerymultiselect,默认情况下选中了selectall选项。 每当所选选项发生更改时,我都会相应地重新加载页面数据 除了点击“全选”按钮不会触发onChange事件,而且点击后我无法重新加载数据之外,其他一切都很好。我尝试将事件处理程序附加到checkAll和selectAll,但没有效果 $("#testselect").multiselect({ nonSelectedText: 'None', allSelectedText: 'Al

我有一个jquerymultiselect,默认情况下选中了selectall选项。 每当所选选项发生更改时,我都会相应地重新加载页面数据

除了点击“全选”按钮不会触发onChange事件,而且点击后我无法重新加载数据之外,其他一切都很好。我尝试将事件处理程序附加到checkAll和selectAll,但没有效果

$("#testselect").multiselect({
        nonSelectedText: 'None',
        allSelectedText: 'All Selected',
        includeSelectAllOption: true,
        buttonWidth: '100%',
        checkAll: function () {
            alert("check all"); // Doesn't work
        },
        selectAll: function () {
            alert("select all"); // Doesn't work
        },
        onChange: function (option, checked, select) {
            alert("onchange") // Works but not for 'All Selected'
            // Do something
        }
});
$("#testselect").multiselect('selectAll', false);
$("#testselect").multiselect('updateButtonText');
添加主复选框:

<th>SELECT ALL<br/><input type="checkbox"  onClick="toggle(this)" /></th>
全选
添加脚本:

          <script>

          function toggle(source) {
           checkboxes = document.getElementsByName('checkbox[]');
           if(x=1)
           {
             for(var i=0, n=checkboxes.length;i<n;i++) {
               checkboxes[i].checked = source.checked;
             }}}



           </script>

函数切换(源){
checkbox=document.getElementsByName('checkbox[]);
如果(x=1)
{
对于(变量i=0,n=复选框。长度;i添加主复选框:

<th>SELECT ALL<br/><input type="checkbox"  onClick="toggle(this)" /></th>
全选
添加脚本:

          <script>

          function toggle(source) {
           checkboxes = document.getElementsByName('checkbox[]');
           if(x=1)
           {
             for(var i=0, n=checkboxes.length;i<n;i++) {
               checkboxes[i].checked = source.checked;
             }}}



           </script>

函数切换(源){
checkbox=document.getElementsByName('checkbox[]);
如果(x=1)
{
对于(var i=0,n=checkbox.length;i这对我很有用

$(document).on('click', '.ms-selectall', function( event ){
        //your code
});
这对我有用

$(document).on('click', '.ms-selectall', function( event ){
        //your code
});

使用onSelectAllonSelectAll事件,而不是全选和全选

例如:

$("#testselect").multiselect({
        nonSelectedText: 'None',
        allSelectedText: 'All Selected',
        includeSelectAllOption: true,
        buttonWidth: '100%',
        onChange: function (option, checked, select) {
            alert("onchange") // Works but not for 'All Selected'
        },
        onSelectAll: function () {
            console.log("call when select all");
        },
        onDeselectAll: function () {
            console.log("call when deselect all");
        }
});

使用onSelectAllonSelectAll事件,而不是全选和全选

例如:

$("#testselect").multiselect({
        nonSelectedText: 'None',
        allSelectedText: 'All Selected',
        includeSelectAllOption: true,
        buttonWidth: '100%',
        onChange: function (option, checked, select) {
            alert("onchange") // Works but not for 'All Selected'
        },
        onSelectAll: function () {
            console.log("call when select all");
        },
        onDeselectAll: function () {
            console.log("call when deselect all");
        }
});

这是您使用的multiselect吗?因为我没有看到onChange()方法这是您使用的multiselect吗?因为我没有看到onChange()方法