jquery UI tabs and dialog modal confirmation issue

jquery UI tabs and dialog modal confirmation issue

Hi,
I have this issue I've been trying to solve but i cannot find an easy
solution to it yet. I'm using jQuery tabs and jquery dialog. In my web
application i have a couple of tabs with forms on them.
Right now if the user does not fill all the required fields it shows a
pop up (dialog- modal confirmation). But here the problem starts: when
i click on the next tab ofcourse it shows the pop up but it goes to
the next tab and it does not wait on the confirmation. Well with tabs
event 'select' you can prevent it from going to the next tab but then
the 'yes' or 'no' values does not work properly (because the dialog
buttons don't have they own click event) so i'm basically stuck right
now here is some exaple code:
$('#tabs').bind('tabsselect', function(event, ui) {
var theURL = ui.tab;
if (fgDialog) {
fgDialog = false;
return true;
}
$("div#dvOrganisatie form").validate();
if (!($("div#dvOrganisatie form").valid())) {
getDialog(theURL);
return false;
}
else { return true; };
})
});
function getDialog(theURL) {
var targetUrl = theURL;
$("#dialog").dialog({ autoOpen: false, modal: true,
buttons: { "No": function() { $(this).dialog("close"); fgDialog =
false; }, "Yes": function() { var $tabs = $('#tabs').tabs(); $
("#tabs").tabs('select', 2); $(this).dialog("close"); fgDialog =
true;} }
});
$("#dialog").dialog("open");
};
It works great when you click 'No' it stays on that tab page. But with
'yes' it doesn't have the desired effect. This is not the final code
version. It is more more of a test code to see how the plugin was
reacting to my code. (and ofcourse i found out when i click on 'yes'
or 'no' it just triggers the tabsselect event. So that it is why it is
not working accordingly).
What can i do to overcome this problem? any suggestion is appreciated.
adwen
--