[英]Close dialog onclick close icon in alertify.js
我正在使用Alertify對話框,並且在對話框中添加了一個關閉圖標,如下所示
<span class='close-button' id='closebutton'></span>
我試圖按如下方式關閉對話框onclicking關閉關閉圖標。 但是我面臨一個錯誤,因為“初始化前無法在對話框上調用方法;嘗試定義方法'close'closebutton的嘗試未定義”。 並且無法關閉對話框。 請讓我知道是否有任何解決方案。 提前致謝。
$("#closebutton").on( 'click', function () { $('#submitdialog').dialog('close');
});
您可以使用對話框的名稱來訪問關閉方法:
首先創建對話框:
alertify.dialog('myAlert',function(){
return{
main:function(message){
this.message = message;
},
setup:function(){
return {
buttons:[{text: "cool!", key:27/*Esc*/}],
focus: { element:0 }
};
},
prepare:function(){
this.setContent(this.message);
}
}});
然后,您可以通過以下方式關閉它:
//close it
alertify.myAlert().close()
注意,myAlert是對話框的名稱。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.