Please check the dialog which opened is or not '#cdConfirm' object created.
If not, it is normally.

2009/12/21 Ladio <vladimir.m...@gmail.com>

> Hello Steve,
>
> First of all thank you very much for your time and efforts.
>
> For each record in the grid there is a link that will will call a
> javascript function delete_product().
>
> I pass to the js function the product id, and the labels for the two
> buttons (delete and cancel). The rest of the code of the function is
> the one i show in the first post:
>
> function delete_product(productId, deleteLable, cancelLable){
> var buttons = {};
> buttons[deleteLabel] = function(){
>  $.ajax({
>  ...
>  error: function(){
>    // display error
>    $("#cdConfirm").dialog("close");
>  },
>  success: function(msg){
>  // show success message
>  // close dialog
>  $("#cdConfirm").dialog("close");
>  }
>  )};
> }
>
> buttons[cancelLabel] = function(){$(this).dialog('close');}
>
> $("#cdConfirm").dialog({
>  bgiframe: true,
>  draggable: false,
>  resizable: false,
>  modal: true,
>  overlay: {
>  backgroundColor: '#a09987',
>  opacity: 0.5
>  },
>  buttons: buttons
> });
>
> $("#cdConfirm").dialog("open")
>
> }
>
> Looking at the function i can say that every time the users click on
> the delete link the dialog will open and closed again. The two ways of
> closing the dialog are either by clicking the "X" button of the
> dialog, "Cancel" button that i provide or programatically. Even in the
> ajax fails i still close the dialog ( $("#cdConfirm").dialog
> ("close"); ).
>
> Since the first time everything works fine, i suspect that I'm doing
> something wrong with opening and closing the dialog. I also tried to
> use 'destroy' instead of 'close' but still no luck.
>
> I used the .dialog('isOpen') just for the sake of debugging. I was
> going through the documentation and i saw it out and thought it will
> be of some help. I also added the autoOpen = false but still the
> problem is there.
>
> Thanks in advance,
> Vladimir
>
>
>
>
>
>
>
> On Dec 21, 2:02 pm, Steven Black <ste...@stevenblack.com> wrote:
> > I'm looking at the code in ui.dialog.js.
> >
> > Tell me, how is your Delete button materializing the dialog?  See,
> > ('#dialog_name').dialog('isOpen') does not query the state of the
> > dialog pane.  It's just a state-flag with no context-specific smarts
> > at all.
> >
> > For example, you could say '#dialog_name').show() or .hide() and that
> > doesn't change the value of Dialog._isOpen.  It's just a dumb flag,
> > yet it controls various aspects of the dialog.
> >
> > So tell us more about the code behind your Delete button.
> >
> > Another consideration: the code only closes the dialog upon Ajax
> > success.  What about the non-success case?  There's a "complete"
> > callback that is invoked in either case...
> >
> > **--**  Steve
> >
> > On Dec 20, 11:46 pm, Ladio <vladimir.m...@gmail.com> wrote:
> >
> >
> >
> > > Hi Steve,
> >
> > > I tried your suggestion and i can see the HTML for the dialog pane.
> > > It's ID is "cdConfirm" in both cases, when it works and when it
> > > doesn't work. I really don't know why it is not working :( Actually
> > > the code that i wrote above i have included in a javascript function
> > > (deleteProduct(....)), so every time i click on delete icon, the
> > > function will be called... I don't know if that's wrong...
> >
> > > On Dec 21, 12:25 pm, Steven Black <ste...@stevenblack.com> wrote:
> >
> > > > Depending on which browser you are using, what do you see when you
> > > > Right+Click and "Inspect element" while the mouse cursor is on the
> > > > dialog?  You should see the HTML code belonging to the dialog pane
> > > > and, from that, the proper ID.
> >
> > > > **--**  Steve
> >
> > > > On Dec 20, 11:57 am, Ladio <vladimir.m...@gmail.com> wrote:
> >
> > > > > Hi everyone,
> >
> > > > > I'm facing a problem with the usage of the UI dialog. I have a page
> > > > > that displays a grid. Each record in the grid has a delete button.
> > > > > When the delete button is clicked a jQuery dialog opens and asks
> for
> > > > > confirmation (it contains 'Cancel' and 'Delete' buttons). If delete
> > > > > button is clicked, an ajax call will be made to the server to
> delete
> > > > > the record and then call .dialog('close') to close the dialog.
> >
> > > > > So, basically the following are the steps:
> >
> > > > > 1. click the delete button
> > > > > 2. jQuery dialog opens
> > > > > 3. click the delete button
> > > > > 4. send ajax request to server
> > > > > 5. close the dialog
> >
> > > > > When i open the page and try to delete a record from the grid
> > > > > everything works fine. When i try to delete another record, the
> dialog
> > > > > opens, after clicking the delete button the ajax request is made,
> but
> > > > > when i try to close the dialog [ $('#dialog_name').dialog('close;)
>  ],
> > > > > it doesn't get closed. I tried to check if the dialog is open [ $
> > > > > ('#dialog_name').dialog('isOpen') ] and it returns FALSE. That is
> very
> > > > > strange because the dialog is already opened...
> >
> > > > > The code is as follows:
> >
> > > > > var buttons = {};
> > > > > buttons[deleteLabel] = function(){
> > > > >  $.ajax({
> > > > >   ...
> > > > >  error: function(){
> > > > >     // display error
> > > > >  },
> > > > >  success: function(msg){
> > > > >   // show success message
> > > > >   // close dialog
> > > > >   $("#cdConfirm").dialog('close');
> > > > >  }
> > > > >  )};}
> >
> > > > > buttons[cancelLabel] = function(){$(this).dialog('close');}
> >
> > > > > $("#cdConfirm").dialog({
> > > > >  bgiframe: true,
> > > > >  draggable: false,
> > > > >  resizable: false,
> > > > >  modal: true,
> > > > >  overlay: {
> > > > >   backgroundColor: '#a09987',
> > > > >   opacity: 0.5
> > > > >  },
> > > > >  buttons: buttons
> >
> > > > > });
> >
> > > > > I really appreciate any help.
> >
> > > > > Thanks in advance,
> > > > > Ladio
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "jQuery UI" group.
> To post to this group, send email to jquery...@googlegroups.com.
> To unsubscribe from this group, send email to
> jquery-ui+unsubscr...@googlegroups.com<jquery-ui%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/jquery-ui?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to jquery...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-ui+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en.


Reply via email to