甜蜜警报后文件上传 window
File upload window after Sweet Alert
用例:
我正在尝试将 window.alert
更改为 Sweet alert。
当我使用window.alert
时,上传文件前出现警告弹窗window,然后点击'OK',出现文件上传window
- 但是,将
window.alert
更改为Sweet alert后,文件上传window同时出现。
<label for="ScanFile"><i class="fa fa-upload" style='cursor: pointer;' ng-click="uploadAlert(row)"></i></label>
<input id="ScanFile" type="file"/>
当用户点击标签时,Sweet-alert出现,然后用户可以select文件。
uploadAlert() :
$scope.uploadAlert = function() {
$window.alert(~~~~~~);
}
如何解决这个问题?
<label for="ScanFile"><i class="fa fa-upload" style='cursor: pointer;' ng-click="uploadAlert(event, row)"></i></label>
<input id="ScanFile" type="file"/>
您的 uploadAlert() 函数将类似于,
$scope.uploadAlert = function(e) {
e.preventDefault(); // this will prevent the upload dialog from opening
swal(); // sweetalert popup
}
现在您可以使用 id 以编程方式单击 <input id="ScanFile" type="file"/>
,以在关闭 sweetalert 对话框后打开对话框。
document.getElementById("ScanFile").click();
例如:
$scope.uploadAlert = function(e) {
e.preventDefault(); // this will prevent the upload dialog from opening
swal({
title: 'Demo',
text: 'Demo',
showCancelButton: true,
confirmButtonText: 'Submit',
},
function() {
document.getElementById("ScanFile").click();
});
});
}
用例:
我正在尝试将
window.alert
更改为 Sweet alert。当我使用
window.alert
时,上传文件前出现警告弹窗window,然后点击'OK',出现文件上传window- 但是,将
window.alert
更改为Sweet alert后,文件上传window同时出现。<label for="ScanFile"><i class="fa fa-upload" style='cursor: pointer;' ng-click="uploadAlert(row)"></i></label> <input id="ScanFile" type="file"/>
当用户点击标签时,Sweet-alert出现,然后用户可以select文件。
uploadAlert() :
$scope.uploadAlert = function() {
$window.alert(~~~~~~);
}
如何解决这个问题?
<label for="ScanFile"><i class="fa fa-upload" style='cursor: pointer;' ng-click="uploadAlert(event, row)"></i></label>
<input id="ScanFile" type="file"/>
您的 uploadAlert() 函数将类似于,
$scope.uploadAlert = function(e) {
e.preventDefault(); // this will prevent the upload dialog from opening
swal(); // sweetalert popup
}
现在您可以使用 id 以编程方式单击 <input id="ScanFile" type="file"/>
,以在关闭 sweetalert 对话框后打开对话框。
document.getElementById("ScanFile").click();
例如:
$scope.uploadAlert = function(e) {
e.preventDefault(); // this will prevent the upload dialog from opening
swal({
title: 'Demo',
text: 'Demo',
showCancelButton: true,
confirmButtonText: 'Submit',
},
function() {
document.getElementById("ScanFile").click();
});
});
}