1
我遇到了Blueimp JQuery AJAX文件上傳插件的問題。 我想要做的就是綁定一個函數到上傳按鈕來顯示確認提醒,當點擊上傳按鈕時。問題是我正在使用ajax調用中的add:選項,並且這會在選擇要上載的文件時添加函數,這會導致確認消息顯示x次,用戶選擇要上載的文件。有沒有辦法解決這個問題?上傳前確認按鈕點擊Blueimp JQuery文件上傳
function setUploadBtnForm1(token){
var regexp = new RegExp("/settings\$", "i");
var url = window.location.origin + window.location.pathname.replace(regexp, '/ajaxUploadSigFile');
$('#fileUpload').fileupload({
formData: {_token: token},
datatype:'json',
url:url,
allowedTypes:'png',
add:function(e, data){
$('#signatureUploadBtn1').click(function(){
var response = confirm('This will remove the existing signature are you sure?');
if(response == true)
{
data.submit();
}else{
e.preventDefault();
}
});
},
success: function(data){
var query = data;
if (query.RESULT == 'PASS')
{
$('#signatureUploadBtn1').hide();
//set src attribute of signature image to filename of uploaded file.
$('.sigImage1').attr('src', '../images/signatures/'+query.FILENAME);
$('.modalLoadContent').fadeOut('fast');
$('.modalFinishContent').show();
}else{
$('#signatureUploadBtn1').text('Failed!');
}
}
})
}