2016-08-16 215 views
1
swal({ 
     title: "Log In to Continue", 
     html: true, 
     text: "Username: <input type='text'><br>Password: <input type='password'>", 
     type:"input" 
}); 

enter image description hereSweet Alert沒有佔用兩個輸入區域?

+0

如果你檢查這個元素,你的瀏覽器告訴你這是什麼? – Dandy

+0

https://github.com/plataformatec/devise/wiki/Disable-password-confirmation-during-registration – Sarath

+0

未捕獲錯誤:Bootstrap的JavaScript需要jQuery –

回答

0
$(document).ready(function() { 
    swal({ 
title: "Error!", 
    text: "Here's my error message!", 
    type: "error", 
    confirmButtonText: "Cool" 
    }); 
    }); 
+0

你啓動這個標記 satwick

+0

我已經添加了它,但它不工作。 –

+0

據我所知,你無法做到現成的產品。你可以使用fork或者實現,或者僅僅使用HTML元素作爲模式參見引導模型中的例子(例如:http://getbootstrap.com/javascript/#modals) – satwick

0

按你的意見,我想你忘了,包括在你的代碼的jquery.js嘗試將其包含在腳本比試試這個代碼

<style>fieldset{ 

     display:none; 

     } 
<style> 
$(document).ready(function() { 
    swal({ 
title: "Log In to Continue", 
     html: true, 
     text: "Username: <input type='text'><br>Password: <input type='password'>", 
     type:"input" 
    }); 
    }); 
+0

這個代碼顯示了3個輸入區域.. –

+0

它似乎是錯誤嘗試在代碼中添加提及的樣式表來臨時解決..fieldset { display:none; } –

0
swal({ 
    title: 'Multiple inputs', 
    html: 
    '<input id="swal-input1" class="swal2-input" autofocus>' + 
    '<input id="swal-input2" class="swal2-input">', 
    preConfirm: function() { 
    return new Promise(function(resolve) { 
    if (result) { 
     resolve([ 
     $('#swal-input1').val(), 
     $('#swal-input2').val() 
     ]); 
     } 
    }); 
    } 
    }).then(function(result) { 
swal(JSON.stringify(result)); 
      }) 
+0

試試這個我想這是你的答案 – satwick

+0

添加了這些鏈接 satwick

0

類型:「input 「將.sweet-alert輸入到顯示塊,並啓用您自己的輸入將Id /類名稱添加到輸入,並使用css將它們設置爲」display:block!important「。

實施例的代碼段

$("#btnShowAlert").click(function() { 
 
    sweetAlert({ 
 
    title: "Log In to Continue", 
 
    text: "Username: <input id='userName' type='text'><br>Password: <input id='password' \t type='password'>", 
 
    html: true 
 
    }); 
 

 
});
.sweet-alert #userName, 
 
.sweet-alert #password { 
 
    display: block !important; 
 
}
<link href="http://tristanedwards.me/u/SweetAlert/lib/sweet-alert.css" rel="stylesheet"/> 
 
<script src="http://tristanedwards.me/u/SweetAlert/lib/sweet-alert.js"></script> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
 
<button id="btnShowAlert"> 
 
    Show Sweet Alert 
 
</button>

0

我面臨相同的工作在R,在一個變通解決方案的一部分周圍是這樣做的:

sweetalert(title : "test message", 
       text : "Username: <input type='text'><br>Password:", 
       html : TRUE, 
       type : "input", 
       confirmButtonColor : '#DD6B55', 
       confirmButtonText : 'Yes, merge the files!', 
       closeOnConfirm : FALSE) 

我想。這會給你只有2而不是3個輸入字段