[英]sweetalert dialog box with textbox in Chrome
我在使用Chrome文本字段的sweetalert對話框時遇到問題。 它在mozila中工作正常,但在chrome中不工作。 警報框有效,但不允許在texbox中輸入值。
下面是jQuery
function sendmail(val){
swal({
title: "Send E-Mail",
text: "<input type='email' class='form-control' name='email' id='email'/>",
showCancelButton: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Send",
html: true,
closeOnConfirm: false
},
function (isConfirm) {
if (isConfirm) {
var email = $("#email").val();
var dataString = 'email=' + email + '&id=' + val;
$.ajax({
type: "POST",
url: "../class/sendmail.php",
data: dataString,
cache: false,
success: function (result) {
swal("sent!", "Your Mail has been sent.", "success");
}
});
}
});}
我認為這是兩件事,首先,您使用的是“甜蜜警報”的輸入錯誤。 您想要將甜蜜警報的類型更改為輸入。
swal({
title: "An input!",
text: "Write something interesting:",
type: "input",
showCancelButton: true,
closeOnConfirm: false,
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");
});
摘自sweetalert 網站上的示例
同樣,在DOM加載后添加input#email時,您需要使用類似jQuery的.on()功能。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.