[英]How to pass the return value of jquery dialogue box button function in some called function
我想獲取jquery對話框的返回值,取決於對話的返回值是true還是false我需要調用其他函數,這是我的試用版,但是這里是返回[object object]。
function someFunction()
{
returnVal=$('#uploadMsrDialog').dialog('open');
alert(returnVal);// RETURNING [object object]
if(returnVal==true)
{
do some thing...
}
}
這是我的對話框打開腳本:
$(function() {
$('button#btnAdmViewRej').click(function(){
$('#uploadMsrDialog').dialog('open');
});
$('#uploadMsrDialog').dialog({
autoOpen: false,
width: 250,
height: 200,
position: 'top',
modal: true,
resizable: false,
buttons: {
"OK":function()
{
callback(true);
});
$(this).dialog("close");
},
"Close": function() {
callback(false);
$(this).dialog("close");
}
} //end of buttons:
});
function callback(val)
{
return val;
}
function someFunction()
{
var returnVal=$('#uploadMsrDialog').dialog('open');
/*
returnVal is a jquery wrapper object $('#uploadMsrDialog').
At this point the dialog is shown and is waiting for
the user to click OK or Close. The execution continues and
someFunction exits. callback function has not
executed yet.
*/
}
取決於用戶單擊的內容(確定或關閉)的邏輯應在callback
:
function callback(val)
{
if(val)
{
do some thing...
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.