Reputation: 363
I want to get the return value of jquery dialogue box, depends on return value true or false of dialogue I need to call some other function , Here is my trial,but here it is returning [object object].
function someFunction()
{
returnVal=$('#uploadMsrDialog').dialog('open');
alert(returnVal);// RETURNING [object object]
if(returnVal==true)
{
do some thing...
}
}
Here is my dialogue box open script :
$(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;
}
Upvotes: 0
Views: 204
Reputation: 15893
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.
*/
}
The logic that depends on what user clicked (OK or Close) should be in callback
:
function callback(val)
{
if(val)
{
do some thing...
}
}
Upvotes: 2