diff --git a/ietf/secr/templates/drafts/edit.html b/ietf/secr/templates/drafts/edit.html
index 1c89d33ae..777c6d0d1 100644
--- a/ietf/secr/templates/drafts/edit.html
+++ b/ietf/secr/templates/drafts/edit.html
@@ -11,54 +11,7 @@
-
+
{% endblock %}
{% block breadcrumbs %}{{ block.super }}
diff --git a/ietf/secr/templates/sreq/edit.html b/ietf/secr/templates/sreq/edit.html
index ef1829e53..f1c7a35bd 100755
--- a/ietf/secr/templates/sreq/edit.html
+++ b/ietf/secr/templates/sreq/edit.html
@@ -9,54 +9,7 @@
-
+
{% endblock %}
{% block breadcrumbs %}{{ block.super }}
diff --git a/ietf/secr/templates/sreq/new.html b/ietf/secr/templates/sreq/new.html
index 9edd700a4..7543fda3b 100755
--- a/ietf/secr/templates/sreq/new.html
+++ b/ietf/secr/templates/sreq/new.html
@@ -9,54 +9,7 @@
-
+
{% endblock %}
{% block breadcrumbs %}{{ block.super }}
diff --git a/ietf/templates/doc/change_shepherd.html b/ietf/templates/doc/change_shepherd.html
index 9a4e075ed..3d1ed0ef3 100644
--- a/ietf/templates/doc/change_shepherd.html
+++ b/ietf/templates/doc/change_shepherd.html
@@ -30,4 +30,5 @@
{% block js %}
+
{% endblock %}
diff --git a/ietf/templates/doc/draft/change_replaces.html b/ietf/templates/doc/draft/change_replaces.html
index c1c71cd68..c27b8cee8 100644
--- a/ietf/templates/doc/draft/change_replaces.html
+++ b/ietf/templates/doc/draft/change_replaces.html
@@ -29,4 +29,5 @@
{% block js %}
+
{% endblock %}
diff --git a/ietf/templates/group/edit.html b/ietf/templates/group/edit.html
index 3d1423588..6046b6a17 100644
--- a/ietf/templates/group/edit.html
+++ b/ietf/templates/group/edit.html
@@ -52,6 +52,7 @@ so. New accounts can be created here.
{% block js %}
+
+
{% endblock %}
diff --git a/ietf/templates/group/stream_edit.html b/ietf/templates/group/stream_edit.html
index b49263b54..8f50c89f8 100644
--- a/ietf/templates/group/stream_edit.html
+++ b/ietf/templates/group/stream_edit.html
@@ -43,4 +43,5 @@
{% block js %}
+
{% endblock %}
diff --git a/ietf/templates/ipr/details_edit.html b/ietf/templates/ipr/details_edit.html
index 68782115a..569389305 100644
--- a/ietf/templates/ipr/details_edit.html
+++ b/ietf/templates/ipr/details_edit.html
@@ -242,6 +242,7 @@
{% block js %}
+
{% endblock %}
diff --git a/ietf/templates/liaisons/edit.html b/ietf/templates/liaisons/edit.html
index 2be67a8cd..c8e4fb86f 100644
--- a/ietf/templates/liaisons/edit.html
+++ b/ietf/templates/liaisons/edit.html
@@ -61,5 +61,6 @@
{% block js %}
+
{% endblock %}
diff --git a/ietf/templates/nomcom/edit_position.html b/ietf/templates/nomcom/edit_position.html
index 681856374..cd6938d57 100644
--- a/ietf/templates/nomcom/edit_position.html
+++ b/ietf/templates/nomcom/edit_position.html
@@ -28,4 +28,5 @@
{% block content_end %}
+
{% endblock %}
diff --git a/static/js/ietf.js b/static/js/ietf.js
index a7f45a71b..b37ff1db0 100644
--- a/static/js/ietf.js
+++ b/static/js/ietf.js
@@ -206,60 +206,6 @@ $(".snippet .show-all").click(function () {
// }
// });
-function setupSelect2Field(e) {
- var url = e.data("ajax-url");
- if (!url)
- return;
-
- var maxEntries = e.data("max-entries");
- var multiple = maxEntries != 1;
- var prefetched = e.data("pre");
- e.select2({
- multiple: multiple,
- minimumInputLength: 2,
- width: "off",
- allowClear: true,
- maximumSelectionSize: maxEntries,
- ajax: {
- url: url,
- dataType: "json",
- quietMillis: 250,
- data: function (term, page) {
- return {
- q: term,
- p: page
- };
- },
- results: function (results) {
- return {
- results: results,
- more: results.length == 10
- };
- }
- },
- escapeMarkup: function (m) {
- return m;
- },
- initSelection: function (element, cb) {
- if (!multiple && prefetched.length > 0)
- cb(prefetched[0]);
- else
- cb(prefetched);
-
- },
- dropdownCssClass: "bigdrop"
- });
-}
-
-$(document).ready(function () {
- $(".select2-field").each(function () {
- if ($(this).closest(".template").length > 0)
- return;
-
- setupSelect2Field($(this));
- });
-});
-
// Use the Bootstrap3 tooltip plugin for all elements with a title attribute
$('[title][title!=""]').tooltip();
diff --git a/static/js/select2-field.js b/static/js/select2-field.js
new file mode 100644
index 000000000..993b57f89
--- /dev/null
+++ b/static/js/select2-field.js
@@ -0,0 +1,55 @@
+// currently we only include select2 CSS/JS on those pages where forms
+// need it, so the generic setup code here is also kept separate
+function setupSelect2Field(e) {
+ var url = e.data("ajax-url");
+ if (!url)
+ return;
+
+ var maxEntries = e.data("max-entries");
+ var multiple = maxEntries != 1;
+ var prefetched = e.data("pre");
+ e.select2({
+ multiple: multiple,
+ minimumInputLength: 2,
+ width: "off",
+ allowClear: true,
+ maximumSelectionSize: maxEntries,
+ ajax: {
+ url: url,
+ dataType: "json",
+ quietMillis: 250,
+ data: function (term, page) {
+ return {
+ q: term,
+ p: page
+ };
+ },
+ results: function (results) {
+ return {
+ results: results,
+ more: results.length == 10
+ };
+ }
+ },
+ escapeMarkup: function (m) {
+ return m;
+ },
+ initSelection: function (element, cb) {
+ if (!multiple && prefetched.length > 0)
+ cb(prefetched[0]);
+ else
+ cb(prefetched);
+
+ },
+ dropdownCssClass: "bigdrop"
+ });
+}
+
+$(document).ready(function () {
+ $(".select2-field").each(function () {
+ if ($(this).closest(".template").length > 0)
+ return;
+
+ setupSelect2Field($(this));
+ });
+});