我的Ajax方法看起来像这样
$.post(url,{
ajax_call:"putDonation",
addresse:addresse,
phone:phone,
email:email,
name:name,
amount:amount,
amountinwords:amountinwords
}).done(function(data){
console.log(data);
var arr = [];
try {
var str = "";
//convert to json string
arr = $.parseJSON(data); //convert to javascript array
$.each(arr,function(key,value){
str +="<li>"+value+"</li>";
});
alert(str);
$(".alert-danger").show();
$("#error").html(str);
} catch (e) {
swal("Jay Gayatri !", 'Donation Sucessful', "success")
$("#donation")[0].reset();
}
})
Run Code Online (Sandbox Code Playgroud)
我想展示一个像这样的甜蜜警报警告弹出窗口
swal({
title: "Are you sure ?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!", …
Run Code Online (Sandbox Code Playgroud) 我正在使用sweetalert的自定义版本来询问我的用户input
.我已经设法使一切工作,但有一个奇怪的行为,为了能够在输入框中输入文本,你必须先点击屏幕:
swal({
title: "Aggiornamento profilo",
text: '<br /><form method="post" id="taxcode-update" name="taxcodeUpdate"><input id="admin-tax-code" minlength="3" class="form-control wedding-input-text wizard-input-pad" type="text" name="taxCode" placeholder="Codice fiscale"></form>',
type: "warning",
showCancelButton: false,
confirmButtonText: "Aggiorna il mio profilo",
closeOnConfirm: false
}, function () {
swal("Deleted!", "Your imaginary file has been deleted.", "success");
});
Run Code Online (Sandbox Code Playgroud)
我不明白如何textarea
在sweet
警报中添加类型.相近type: "input"
$('#saveBtn).click(function(){
swal({
title: "Enter your Name!",
text: "your name:",
type: "input",
showCancelButton: true,
closeOnConfirm: false,
showLoaderOnConfirm: true,
animation: "slide-from-top",
inputPlaceholder: "Write something" },
function(inputValue){
if (inputValue === false)
return false;
if (inputValue === "") {
swal.showInputError("You need to write something!");
return false
}
swal("Nice!", "You wrote: " + inputValue, "success");
});
});
Run Code Online (Sandbox Code Playgroud)
这很好用.但如果我用 type: "textarea"
而不是type: "input"
这给出了这样的错误:
sweetalert.min.js:1 Uncaught ReferenceError: logStr is not defined
Run Code Online (Sandbox Code Playgroud)
感谢帮助.
我想向SweetAlert2输入类型选择添加动态选项,如下所示:
swal({
title: 'Select Ukraine',
input: 'select',
inputOptions: {
'SRB': 'Serbia',
'UKR': 'Ukraine',
'HRV': 'Croatia'
},
inputPlaceholder: 'Select country',
showCancelButton: true,
inputValidator: function(value) {
return new Promise(function(resolve, reject) {
if (value === 'UKR') {
resolve();
} else {
reject('You need to select Ukraine :)');
}
});
}
}).then(function(result) {
swal({
type: 'success',
html: 'You selected: ' + result
});
})
Run Code Online (Sandbox Code Playgroud)
我想添加我自己保存在对象中的选项,而不是这 3 个国家。我怎样才能使用 javascript 做到这一点?
我为Bootstrap和React(我在Meteor应用程序中使用)找到了这个完美的Sweet Alert模块:
http://djorg83.github.io/react-bootstrap-sweetalert/
但我不明白你如何在React组件中包含这些代码.
当有人点击我的应用程序中的删除按钮时,我想要一个Sweet Alert提示弹出要求确认.
这是删除按钮的组件:
import React, {Component} from 'react';
import Goals from '/imports/collections/goals/goals.js'
import SweetAlert from 'react-bootstrap-sweetalert';
export default class DeleteGoalButton extends Component {
deleteThisGoal(){
console.log('Goal deleted!');
// Meteor.call('goals.remove', this.props.goalId);
}
render(){
return(
<div className="inline">
<a onClick={this.deleteThisGoal()} href={`/students/${this.props.studentId}/}`}
className='btn btn-danger'><i className="fa fa-trash" aria-hidden="true"></i> Delete Goal</a>
</div>
)
}
}
Run Code Online (Sandbox Code Playgroud)
以下是我从Sweet Alert示例中复制的代码:
<SweetAlert
warning
showCancel
confirmBtnText="Yes, delete it!"
confirmBtnBsStyle="danger"
cancelBtnBsStyle="default"
title="Are you sure?"
onConfirm={this.deleteFile}
onCancel={this.cancelDelete}
>
You will not be able to recover this imaginary file!
</SweetAlert>
Run Code Online (Sandbox Code Playgroud)
有人知道怎么做吗?
这可能是 ServiceNow 问题,但我添加了一个 Sweet Alert 来显示一个选择框,这样我就可以收集一个值以传递给下一条记录......但选择框没有显示,弹出窗口只是没有框或选项。我错过了什么?屏幕截图: 选择框警报
非常感谢,对我认为添加起来很简单的东西感到非常沮丧:)
swal({
title: 'Select Outage Tier',
input: 'select',
inputOptions: {
'1': 'Tier 1',
'2': 'Tier 2',
'3': 'Tier 3'
},
inputPlaceholder: 'required',
showCancelButton: true,
inputValidator: function (value) {
return new Promise(function (resolve, reject) {
if (value !== '') {
resolve();
} else {
reject('You need to select a Tier');
}
});
}
}).then(function (result) {
swal({
type: 'success',
html: 'You selected: ' + result
});
});
Run Code Online (Sandbox Code Playgroud)
我有一个允许文本输入的SweetAlert2,我给它一个默认值.当警报弹出时,我希望突出显示此默认值,以便用户可以在需要时立即覆盖它.这是一个例子:
以下是我使用sweetAlert选项调用的函数:
window.sweetPrompt = function (title, message, callback, input, keepopen, allowOutsideClick, allowEscapeKey) {
sweetAlert({
title: title,
text: message,
input: 'text',
confirmButtonColor: "#428bca",
preConfirm: function(text) {
return new Promise(function(resolve) {
if (!keepopen) {
resolve();
} else {
callback(text);
}
});
},
inputValidator: function(text) {
return new Promise(function (resolve, reject) {
if (text) {
resolve();
} else {
reject('Cannot be empty!');
}
});
},
inputValue: input,
showCancelButton: true,
reverseButtons: true,
allowOutsideClick: allowOutsideClick,
allowEscapeKey: allowEscapeKey
}).then(callback, function(dismiss){});
};
Run Code Online (Sandbox Code Playgroud)
我将如何做到这一点(如果可能的话)?我想过使用jQuery,但我不知道如何获得sweetAlert对话的引用.任何建议,将不胜感激.
对于 sweetAlert2 我注意到没有“高度”属性但有一个“宽度”属性,有没有办法将对话框的高度设置为 80%?
谢谢
我正在 R Shiny 中使用模态对话来获取用户的输入。在此表单中,默认有一个关闭按钮,单击该按钮即可关闭表单。我想在单击关闭按钮时添加确认弹出窗口(sweetAlert)。
我也准备使用 javascript,但我需要 sweetAlert 而不是 Windows 警报。我也无法成功生成 Windows 警报。
我如何覆盖这个内置“关闭”按钮的功能?我想在有人单击“关闭”时显示警告,并仅在他们确定时才让他们继续。否则我想让他们留在模式对话中。
任何帮助表示赞赏。
例如,我想知道是否有一种方法可以使角度组件在甜蜜的警报框中打开
Swal.fire(
{
HTML: '<app-exampleselector></app-exampleselector>',
})
Run Code Online (Sandbox Code Playgroud)
我的目的是使用组件选择器,而不是在函数内编写代码,这反过来不是一个选项,因为我打算使用很多函数,包括数据库服务函数,这使得代码相当庞大。有没有办法做到这一点?或者我应该决定在新选项卡上打开该组件吗?
sweetalert ×10
javascript ×7
jquery ×4
sweetalert2 ×3
html ×2
ajax ×1
angular ×1
angular9 ×1
angularjs ×1
css3 ×1
modal-dialog ×1
r ×1
reactjs ×1
shiny ×1
typescript ×1