confirm()。
因此,我有事件.on("select2:select", function(e) {}),如果用户从确认对话框中选择取消,我希望阻止select2。
我有以下内容:
$("#select2users").select2().on("select2:select", function(e) {
var data = e.params.data;
if(!confirm("Are you sure you want to ban this user?")) {
e.preventDefault();
}
})
e.preventDefault(); 在这里似乎没有任何作用。
我一直在搜索,但找不到什么好的答案。
应该怎么做?