[英]Prevent a modal from opening again if there is an error
我有一個代碼,可以防止出現錯誤時打開模態,但問題是我下次打開它時即使有錯誤也要打開一次,所以問題是如何在下次出現時阻止它打開再次有錯誤?
這是代碼:
jQuery(".link").click(function(a){
var newVal2 = jQuery("#appID").val();
if(error === '1' || defaultVal2 === newVal2){
alert("Please fill in a valid App ID.");
a.preventDefault();
}
else {
//Access Token Modal
jQuery(".link").colorbox({inline:true, width:"90%"});
a.preventDefault();
//Access Token Modal CLOSING
}
});
PS colorbox
是模式插件。
我認為如果出現錯誤,您應該刪除顏色框:
jQuery(".link").click(function(a){
var newVal2 = jQuery("#appID").val();
if(error === '1' || defaultVal2 === newVal2){
alert("Please fill in a valid App ID.");
$.colorbox.remove()
a.preventDefault();
}
else {
//Access Token Modal
jQuery(".link").colorbox({inline:true, width:"90%"});
a.preventDefault();
//Access Token Modal CLOSING
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.