gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 11:45:42 25 4
gpt4 key购买 nike

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

<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 之前,尝试在点击时验证条件(选择了行?),如下所示:

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

关于javascript - fancybox/jQuery : Why can't I abort after toclick in a button with some relation with fancybox?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26061510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com