Return value from Jquery confirm dialog box -
im trying open jquery confirm box using following code.
var = $('#confirm') .data("x","defaultvalue") .dialog('open'); alert(a.data("x"));
inside dialog tried change value of x.
$("#confirm").dialog({ resizable: false, autoopen: false, height: 180, width: 400, modal: true, buttons: { "leave page": function() { $(this).data("x","this test"); $(this).dialog("close"); }, cancel: function() { $(this).dialog("close"); } } });
how can modified value x. @ moment alert shows "defaultvalue". want "this test".
any thoughts?
ps: can't redirect using window.open() inside dialog.
finally managed solve problem. thought post here, if needs it.
$("#confirm").dialog({ resizable: false, autoopen: false, height: 180, width: 400, modal: true, buttons: { "leave page": function () { var anchorid = $(this).data("anchorid"); var formid = $(this).data("formid"); if (typeof anchorid !== "undefined") window.location.assign(anchorid); if (typeof formid !== "undefined") $(formid).submit(); $(this).dialog("close"); }, cancel: function () { $(this).dialog("close"); } } });
and open confirm dialog
$("a").live("click", function () { if (hasunsaveddata()) { $('#confirm') .data("anchorid", this) .dialog('open'); return false; } else return true; });