Creating a dialog at runtime causes dependency issues

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
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?
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?