fancybox/jQuery:为什么可以'我点击了一个与粉丝盒有关系的按钮后就放弃了

fancybox/jQuery: Why can't I abort after toclick in a button with some relation with fancybox?

本文关键字:一个 放弃 按钮 有关系 为什么 jQuery fancybox      更新时间:2023-09-26

如果在下一个表中选择了一些行:

<table id ="XX">
...
<tr>
<td><input type="checkbox" id="1"></td>
</tr>
...
</table>

我显示此对话框:

jQuery("#btnActivar").fancybox({
    content: jQuery("#ConfirmacionGuardar").html(),
    modal: false,
    showCloseButton: false,
    onComplete: function () {
       ...
    }
});

总是当我点击按钮btnActivar打开fancybox。当在按钮的同一点击事件中没有选择行时,我需要中止它

有可能做到吗?

在决定是否启动fancybox之前,请尝试验证click上的条件(所选行?):

jQuery("#btnActivar").on("click", function () {
    // validate if rows are selected here 
    // returns either true or false, e.g.
    var rows_selected = true;
    // condition true? then fire fancybox programmatically
    if (rows_selected) {
        jQuery.fancybox({
            content: jQuery("#ConfirmacionGuardar").html(),
            modal: false,
            showCloseButton: false,
            onComplete: function () {...
            }
        }); // fancybox
    }; // if
    return false; // otherwise do nothing
}); // on click