Ticket #644 (closed defect: invalid)

Opened 3 years ago

Last modified 3 years ago

QDialogBox duplicates the rendered control when opened/closed multiple times

Reported by: mikederfler Owned by:
Priority: important Milestone: 2.0.2 Stable
Component: QControls Version: 2.0 HEAD
Keywords: QDialogBox Cc:

Description

when looking at line 59 of QDialogBox.class.php

return sprintf('$j("#%s").dialog({%s}); $j("#%s").dialog("open");', $this->strControlId, $strOptions, $this->strControlId);

you can see that calling ShowDialogBox? results in creating a new
dialog (.dialog( ... ) ) but when calling close the created dialog dom elements are not deleted. So two elements with the same id ("my_dialog_id") exist. When the dialog gets opened a second time,
the call to $j("my_dialog_id").dialog() creates 2 new elements with "my_dialog_id". if you made changes to the dialog content between the calls the wrong(old) content gets displayed.
Adding one line fixes it:
$strOptions .= ', close: function() { $j(this).remove(); }';

this deletes the generated elements when hitting the close button.


Attachments

QDialogBox.class.php.diff Download (0.8 KB) - added by mikederfler 3 years ago.

Change History

Changed 3 years ago by mikederfler

Changed 3 years ago by alex94040

  • status changed from new to in_QA

Changed 3 years ago by alex94040

This might also fix #640 - see comments in that bug.

Changed 3 years ago by vakopian

  • status changed from in_QA to closed
  • resolution set to invalid

I don't think the analysis here is correct. If .dialog() has been called on a control before, the subsequent calls will do nothing, they will not initialize a new dialog. Here is some details about how JQuery dialog works:  http://blog.nemikor.com/2009/04/08/basic-usage-of-the-jquery-ui-dialog/

I kinda agree that QDialogBox's implementation is not the best here (I think the initialization code should be called as part of GetControlHtml() or GetEndScript()), but the current implementation is not wrong for calling .dialog() on the same control multiple times.

Whatever problem you're seeing with QDialog, could you check if the patch in #640 fixes it?

Note: See TracTickets for help on using tickets.