![](/img/trans.png)
[英]How to pass the return value of jquery dialogue box button function in some called function
[英]How to pass the button name as variable in jquery dialogue box
我想調用對話框按鈕的默認操作,所以請告訴我如何在對話框初始化旁邊傳遞變量。 這是我的嘗試:
使用默認功能“是”按鈕調用對話框
$( "#confirmComplete" ).dialog( "option", "buttons:Yes");
$( "#confirmComplete" ).dialog({
autoOpen: false,
resizable: false,
modal: true,
async:false,
position: 'top',
buttons: {
"Yes": function() {
//SOME FUNCTIOANLITY
}
}
})
將代碼放在命名函數中,調用該函數:
function doYes() {
// some functionality
}
$("#confirmComplete").dialog({
autoOpen: false,
resizable: false,
modal: true,
async: false,
position: "top",
buttons: {
"Yes": doYes
},
});
doYes(); // Call the default button action
您可以這樣做:
buttons: {
"Yes": function() {
$(this).dialog("close");
return true;
}
}
您還可以使用“ No
按鈕關閉對話框並return false;
根據返回的true
/ false
,您可以采取進一步的措施。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.