如何在某些被调用函数中传递 jquery 对话框按钮函数的 return 值
How to pass the return value of jquery dialogue box button function in some called function
我想获取jquery对话框的return值,取决于对话的return值真或假我需要调用其他函数,这是我的试验, 但这里是 returning [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...
}
}
我想获取jquery对话框的return值,取决于对话的return值真或假我需要调用其他函数,这是我的试验, 但这里是 returning [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...
}
}