- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在删除图像之前使用甜蜜的警报确认。但是,这不起作用。如果我使用 javascript 默认确认,它就可以工作。我尝试使用异步和等待,但没有帮助。我该如何修复/调试这个问题?
var pathURL = "file_path/";
var dropifyElements = {};
$('.dropify').each(function() {
dropifyElements[this.id] = true;
});
var drEvent = $('.dropify').dropify();
drEvent.on('dropify.beforeClear', function(event, element) {
id = event.target.id;
if(dropifyElements[id]) {
var x = false;
return swal({
title: "Are you sure?",
text: "You will not be able undo this operation!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel please!",
closeOnConfirm: false,
closeOnCancel: false
}, function(isConfirm){
if (isConfirm) {
x = true;
} else {
swal({
title:"Cancelled",
text:"Delete Cancelled :)",
type:"error",
timer: 2000,
});
x = true;
}
});
return x;
//return confirm("Do you really want to delete this image?");
// return confirm("Do you really want to delete \"" + element.file.name + "\" ?");
}
});
最佳答案
好的,input
元素通过事件处理程序传递,因此如果用户确实想要删除它,您所要做的就是默认在处理程序上返回 false,那么如果用户点击 swal 实例上的确认按钮,您只需取消输入元素的值即可。我没有你的代码,但这应该可以。
var pathURL = "file_path/";
var dropifyElements = {};
$('.dropify').each(function() {
dropifyElements[this.id] = true;
});
var drEvent = $('.dropify').dropify();
drEvent.on('dropify.beforeClear', function(event, element) {
id = event.target.id;
if(dropifyElements[id]) {
swal({
title: "Are you sure?",
text: "You will not be able undo this operation!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel please!",
closeOnConfirm: false,
closeOnCancel: false
}, isConfirm => {
if (isConfirm) {
element.value = "";
} else {
swal({
title:"Cancelled",
text:"Delete Cancelled :)",
type:"error",
timer: 2000,
});
}
});
return false;
}
});
关于javascript - 如何使用 Sweet Alert 来确认 dropify.js 的图像删除?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50747418/
如何从 sweet.js 宏的参数创建字符串?例如: let foo = macro { rule { $name } => { console.log
如何从参数创建一个字符串到 sweet.js 宏?例如: let foo = macro { rule { $name } => { console.l
用例: 我正在尝试改变 window.alert甜蜜警报。 当我使用 window.alert时,文件上传窗口前出现警告弹出窗口,然后单击“确定”,出现文件上传窗口。 但是,改变后window.ale
如果用户未登录,我一直在尝试进行简单的验证,并尝试在发生这种情况时触发一条甜蜜的警报消息。如果客户尝试将新产品添加到购物车但未登录,则此验证有效。 注意: session 变量是 ASP.NET Co
我的 Sweet Aler 确认对话框有问题。当我单击删除图标时,Sweet Alert 对话框显示不到一秒钟,然后消失并删除该元素。换句话说,我没有机会单击“删除”或“取消”。如何停止这个对话框让我
我想定义一个可转换的甜蜜宏 { a, b } # o 进入 { o.a, o.b } 我目前的尝试是 macro (#) { case infix { { $prop:ident (,) ...
swal({ title: "Log In to Continue", html: true, text: "Username: Password: "
我有一个功能,我可以将我的甜蜜警报对话框装扮起来。我想在很多地方使用它,因此将其设置为如下函数: $rootScope.giveConfirmDialog = function(title,text,
我似乎无法匹配 let function = macro { case infix {$name:ident $[=] | _ ($params ...) { $body ...} } => {
我有一个非常简单的 sweet.js 文件,我正在尝试编译: macro @ { rule { $exp }=>{ + $exp + } } .
我设置了这样的构造函数: ... constructor(props) { super(props); this.state =
下面是我的编码。请告知为什么甜蜜警报只弹出不到 1 秒然后自动重定向到另一个页面。 来自 HTML: $.ajax({ url: "/ABC/AddST/", data: { "use
我有一个带有 php while 循环的 php 页面,在其中我获取用户详细信息和 id。该循环创建按钮,单击这些按钮时,我需要根据其 ID 了解每个按钮的详细信息,如下图所示。 http://tin
我正在使用Sweet Alert JS来提示窗口获取一些输入变量。我试图在函数之外使用这些变量,它们被设置为 NULL,但是当我在函数内部使用它们时,它们被正确设置。我读了一些有关回调函数的内容,但我
我正在尝试编写一个将标记转换为字符串的宏。我当前的宏如下所示: macro stringify { case { $name($token) } => {
我正在使用 Sweet alert library 使用这个库,我发现了奇怪的行为;按键盘的空格键选择警报中的“确认”。但是,在按下“取消”后,在以后的尝试中使用空格键事件“确认”不起作用。(有警报时
我想在宏主体中使用括号来对表达式进行分组。例如: macro m { rule { ($x, $y) } => { $x >>> ($y * 5) } } Sweet.js 删除所有括
我正在创建一个显示非常重要消息的 Sweet Alert,我不希望用户未阅读就关闭它。 因此,为了强调该消息的重要性,我想将“确定”按钮禁用(比方说...)5 秒,这样用户必须至少等待 5 秒才能解除
我在文件“A”中定义了宏。我想在其他文件中使用宏,例如文件 B. 这可能吗?我当然知道我可以在文件 B 中使用宏的编译结果,但我也想在那里使用宏。 一个 macro test { ... } tes
我在一个循环中调用了 sweet alert 函数但是 sweetalert 只显示了一次,我认为它覆盖了之前的 sweetalert,bcz 当我做简单的警报时它确实弹出了两次但是 sweet al
我是一名优秀的程序员,十分优秀!