From 2543f6a1a6e12b490f50e4da69ccc8cac8ac42d8 Mon Sep 17 00:00:00 2001 From: Liane Hampe Date: Tue, 15 Aug 2023 16:03:44 +0200 Subject: [PATCH] Fixes Uncaught TypeError: $(...).select2 is not a function The error occured when trying to create a dmsf link. In such a case select2 must be used in a javascript snippet after jquery and the select2 plugin are loaded. Adding the 'document ready' function ensures that everything is loaded properly before the inline javascript will be executed. --- app/views/dmsf_links/_form.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/dmsf_links/_form.html.erb b/app/views/dmsf_links/_form.html.erb index df1bc658..7a31cd11 100644 --- a/app/views/dmsf_links/_form.html.erb +++ b/app/views/dmsf_links/_form.html.erb @@ -110,8 +110,8 @@ <% end %> - <%= late_javascript_tag do %> +$(document).ready(function(){ <%# Select2 extension, TODO: in case of a modal window, select2 makes problems %> <% unless modal || @fast_links %> $('#dmsf_link_target_project_id').select2(); @@ -148,4 +148,5 @@ labelUrl.append(' *'); } }); +}); <% end %>