Page 1 of 1

Creating a dialog at runtime causes dependency issues

PostPosted: 13 May 2021 13:19
by omonien
Hi!

I am creating a dialog at runtime (async button click), which technically works.

There are problems though if there are JQControls on the dialog. Apparently, their dependencies are not resolved correctly. This results in incomplete/missing functionality.

delphi code
procedure TIWForm1.IWCGJQButton1JQButtonOptionsClick(Sender: TObject; AParams: TStringList);
begin
var LDialog := TIWCGJQDialog.Create(self);
LDialog.Name := 'Dialog1';
LDialog.Parent := self;
LDialog.JQDialogOptions.Title := 'Test';

var LDropdown := TIWCGJQDropDown.Create(LDialog);
LDropdown.Parent := LDialog;
LDropDown.Name := 'Dropdown1';
LDialog.Show;
end;


This makes the Dialog show as expected, but the Dropdown misses all of its extended functionality from "select2()". Inspecting the requests, it seems that the required dropdown.js files are not loaded.

Adding LDialog.AjaxReRender; after Ldialog.Show; adds a lot more to the response, including the required js files, which are loaded successfully. Yet, the calls to .select2() still result in errors - probably because they are executed before the js files are loaded.
And the dialog does not show up anymore - probably because the errors break the display process.

Any ideas?

Re: Creating a dialog at runtime causes dependency issues

PostPosted: 13 May 2021 14:29
by Alexander Bulei

Re: Creating a dialog at runtime causes dependency issues

PostPosted: 14 May 2021 08:44
by omonien
Hi Alexander,

thanks for following up.

In that other post, the issue was that the developer forgot to assign Name/Parent to the dialog. In my simplified example code, you can see that I am assigning Owner, Parent, and Name to the dialog and the inner control.

Without AjaxReRender, the dialog shows up, including the dropdown. The dropdown is not functional though, the required call(s) to .select2() (of the underlying JQ widget) seem to bemissing.

If you add an AjaxReRender, then I can see the required drowpdown.js files and calls to .select2() - but the dialog does not show up, likely because of a wrong order (before the js files are loaded?). See screenshot. I can send a trivial demo if you want.

Bildschirmfoto 2021-05-14 um 09.41.57.png

Re: Creating a dialog at runtime causes dependency issues

PostPosted: 29 Jun 2021 16:45
by Alexander Bulei
Hi,
You always need AjaxReRender if you create the components in runtime, and when use dialog.

So, check the console when you use AjaxReRender.

BR

Re: Creating a dialog at runtime causes dependency issues

PostPosted: 30 Jun 2021 07:45
by omonien
Thanks, I am actually working on a solution, that would call AjaxRerender on all related components, automatically.