diff --git a/app/javascript/stockaid/donations.js b/app/javascript/stockaid/donations.js
index 702405a5..497e3a4f 100644
--- a/app/javascript/stockaid/donations.js
+++ b/app/javascript/stockaid/donations.js
@@ -34,7 +34,14 @@ $(document).on("change", "#donor-selector", function(event) {
case "new":
var content = tmpl("new-donor-template", {});
$("#new-donor-fields").html(content).show();
- return initializeExternalTypeSelector();
+
+ $("#external-type").select2({
+ placeholder: "Select a type",
+ theme: "bootstrap",
+ width: "100%"
+ });
+
+ return;
default:
content = tmpl("existing-donor-template", option.data());
return $("#existing-donor-fields").html(content).show();
diff --git a/app/javascript/stockaid/external_type_select2.js b/app/javascript/stockaid/external_type_select2.js
index 45dbc592..a8f9aeeb 100644
--- a/app/javascript/stockaid/external_type_select2.js
+++ b/app/javascript/stockaid/external_type_select2.js
@@ -1,10 +1,7 @@
-/*
- * decaffeinate suggestions:
- * DS102: Remove unnecessary code created because of implicit returns
- * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
- */
-expose("initializeExternalTypeSelector", () => $(document).ready(() => $("#external-type").select2({
- placeholder: "Select a type",
- theme: "bootstrap",
- width: "100%"
-})));
+$(document).on("turbolinks:load", () => {
+ $("#external-type").select2({
+ placeholder: "Select a type",
+ theme: "bootstrap",
+ width: "100%"
+ });
+});
diff --git a/app/views/donors/edit.html.erb b/app/views/donors/edit.html.erb
index bbffa084..f67897ce 100644
--- a/app/views/donors/edit.html.erb
+++ b/app/views/donors/edit.html.erb
@@ -3,10 +3,6 @@
<% content_for :content_size, "col-sm-9 col-md-10" %>
<% content_for :content do %>
- <%= javascript_tag do %>
- initializeExternalTypeSelector();
- <% end %>
-
<%= form_for @donor, data: { guarded: true } do |f| %>
<%= render partial: "donors/donor_fields", locals: { donor: @donor, fields: f } %>
diff --git a/app/views/donors/new.html.erb b/app/views/donors/new.html.erb
index 2cafc6db..963b9b92 100644
--- a/app/views/donors/new.html.erb
+++ b/app/views/donors/new.html.erb
@@ -4,8 +4,6 @@
<% content_for :content do %>
<%= javascript_tag do %>
- initializeExternalTypeSelector();
-
function onExternalIdChange() {
var value = $(this).val();
$("#save_and_export").prop("disabled", value != "");
diff --git a/app/views/organizations/edit.html.erb b/app/views/organizations/edit.html.erb
index 68d90cbb..b963128e 100644
--- a/app/views/organizations/edit.html.erb
+++ b/app/views/organizations/edit.html.erb
@@ -3,10 +3,6 @@
<% content_for :content_size, "col-sm-9 col-md-10" %>
<% content_for :content do %>
- <%= javascript_tag do %>
- initializeExternalTypeSelector();
- <% end %>
-
<%= form_for @organization, data: { guarded: true } do |f| %>