[Pas2js] bootstrap 5 modal: JQuery(...).modal is not a function

Luca Olivetti luca at ventoso.org
Fri Aug 11 14:06:40 CEST 2023


El 11/8/23 a les 13:37, Luca Olivetti via Pas2js ha escrit:
> El 11/8/23 a les 13:32, Michael Van Canneyt ha escrit:
>>
>>
>> On Fri, 11 Aug 2023, Luca Olivetti via Pas2js wrote:
>>
>>> El 11/8/23 a les 13:01, Michael Van Canneyt via Pas2js ha escrit:
>>>
>>>>
>>>> The latter: Import jquery with a tag, make sure it is before the 
>>>> bootstrap js.
>>>> (bootstrap 5 tries to detect the presence of jquery, so jquery must 
>>>> be first)
>>>>
>>>> I use bootstrap 5 with the libbootstrap in several commercial 
>>>> projects, so I am quite sure it works :-)
>>>
>>> Well, I must be doing something wrong since it gives me that 
>>> exception here. Maybe I should delay the rtl.run() ("Run RTL when all 
>>> page resources are fully loaded")?
>>
>> Maybe. It depends on where you set the script elements. If they are in 
>> the <head></head> then it should not be necessary.
> 
> Yes, they are in <head> and apparently it is necessary.
> OTOH, even if it now works, I introduced a dependency on jquery that I 
> don't strictly need.

BTW, the "Backdrop" property is defined as boolean, however it has to be 
the text 'static' (according to the documentation even in bootstrap 4).
I did this

--- a/packages/bootstrap/bootstrapwidgets.pp
+++ b/packages/bootstrap/bootstrapwidgets.pp
@@ -847,12 +847,19 @@ end;
  procedure TBootstrapModal.ApplyWidgetSettings(aElement: TJSHTMLElement);

  begin
-  JQuery(aElement).modal(New([
-    'backdrop', BackDrop,
-    'keyboard', keyboard,
-    'focus',Focus,
-    'show',ShowOnRender
-  ]));
+  if BackDrop then
+    JQuery(aElement).modal(New([
+      'backdrop', 'static',
+      'keyboard', keyboard,
+      'focus',Focus,
+      'show',ShowOnRender
+    ]))
+  else
+    JQuery(aElement).modal(New([
+      'keyboard', keyboard,
+      'focus',Focus,
+      'show',ShowOnRender
+    ]));
    jQuery(aElement).on_('hidden.bs.modal', at BootstrapHide);
  end;


but I'm not sure if the backdrop property was intended to work the other 
way round.

Bye
-- 
Luca


More information about the Pas2js mailing list