Thanks, Yes I do understand.
My issue was: the beforeClose would return false the FIRST time the user
clicked x, and that works fine. At that point I show the panel with the
"Are you sure you want to close? 'yes' 'no'". If I try to call the
.dialog('close') on "yes" the beforeClose would still return false. I
suppose at that point I could have cleared out the form data on 'yes' so my
CloseNotesDialog() dialog function would return true or set an overrride
flag.
I was going in cirlces because $('#notesDialog').dialog('option',
'beforeclose', function(ev, ui) {return true;}); WAS NOT WORKING.
To be exact because of some business logic I have to perform on the server
side, I was trying the following:
ScriptManager.RegisterStartupScript(this.Page,
this.Page.GetType(), "CloseNotesDialog", "NotesDialog().dialog('option',
'beforeclose', function(event, ui) {return true;});
NotesDialog().dialog('close');", true);
The reason it was not working was becuase I downloaded the 1.7.2 version of
the ui.js. When I did that, and that alone, NONE OF MY POSTBACK EVENTS
WOULD FIRE. I rolled back to 1.7.1 and everything worked perfectly.
Of course in the above I have to rehook the beforeclose when the dialog is
popped: function popNotesDialog() { NotesDialog().dialog('option',
'beforeclose', function(event, ui) {return CloseNotesDialog();});
NotesDialog().dialog('open'); }
P.S. I guess a nice thing to have would be something like:
NotesDialog().dialog('open', ignoreBeforeClose);
On Fri, Nov 20, 2009 at 9:00 AM, Mean Mike <[email protected]> wrote:
> I think your confused about what beforeclose does,
>
> beforeclose doesn't close a dialog it does whatever you put in its
> function right after dialog('close') is called
>
> so you would do somthing like this
>
> $(document).ready(function() {
> $('#notesDialog').dialog({
> autoOpen: false,
> width: 590,
> resizable: false,
> draggable: false,
> bgiframe: true,
> modal: true,
> beforeclose: function(event, ui) {
> return CloseNotesDialog();
> }
> buttons: {
> OK: function() {
> $(this).dialog('close');
> }
> }
> });
> });
>
> function CloseNotesDialog()
> {
> var subject = $('#<%= txtSubject.ClientID %>');
> var note = $('#<%= txtNote.ClientID %>');
>
> if (subject.val() != '' || note.val() != '')
> {
> var pnlNotes = $('#<%= pnlNotes.ClientID %>');
> var pnlNotesConfirmation = $('#<
> %=pnlNotesConfirmation.ClientID %>');
>
> pnlNotesConfirmation.height(pnlNotes.height());
> pnlNotes.hide();
> pnlNotesConfirmation.show();
>
> return false;
> }
> }
>
>
> and when the user clicks "OK" your CloseNoteDialog() function would be
> called
>
> if your trying to determine if the dialog should close or not your
> should do that in "OK"'s funtion
>
> Make sense ?
>
> Mike
>
> On Nov 19, 10:24 am, Nabeal <[email protected]> wrote:
> > I'm at a loss. I have hooked a beforeclose function, and that works
> > fine.
> > The issue that is killing me is when I want to close the dialog after
> > the beforeclose returns false, nothing happens!!
> > On the pnlNotesConfirmation there is a "No" button. On that "No" I
> > try to perform: $('#notesDialog').dialog('close'); No event action
> > occurs.
> >
> > I tried the following line first: $('#notesDialog').dialog('option',
> > 'beforeclose', function(ev, ui) {return true;});
> > Still it doesn't close.
> >
> > The only way I got to work was by doing a destroy ($
> > ('#notesDialog').dialog('destroy'); ) then re init the dialog. That
> > can't be right. What am I doing wrong.
> > Using 1.7.2
> >
> > $(document).ready(function() {
> > $('#notesDialog').dialog({
> > autoOpen: false,
> > width: 590,
> > resizable: false,
> > draggable: false,
> > bgiframe: true,
> > modal: true,
> > beforeclose: function(event, ui) { return CloseNotesDialog
> > (); }
> > });
> > });
> >
> > function CloseNotesDialog()
> > {
> > var subject = $('#<%= txtSubject.ClientID %>');
> > var note = $('#<%= txtNote.ClientID %>');
> >
> > if (subject.val() != '' || note.val() != '')
> > {
> > var pnlNotes = $('#<%= pnlNotes.ClientID %>');
> > var pnlNotesConfirmation = $('#<%=
> > pnlNotesConfirmation.ClientID %>');
> >
> > pnlNotesConfirmation.height(pnlNotes.height());
> > pnlNotes.hide();
> > pnlNotesConfirmation.show();
> >
> > return false;
> > }
> > }
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "jQuery UI" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<jquery-ui%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/jquery-ui?hl=.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"jQuery UI" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jquery-ui?hl=.