Skip to content

Commit eab66c0

Browse files
committed
Fix select2 elements breaking on back button. Fixes #1107
1 parent 87d9c7e commit eab66c0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

app/assets/javascripts/application.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ window.loadCalendar = function(url) {
7878
return true;
7979
}
8080

81+
// Fix select2 elements being duplicated when the back button is clicked.
82+
// Unfortunately causes the content of the field to be lost if it wasn't saved.
83+
document.addEventListener("turbolinks:before-cache", function() {
84+
$('.js-select2').select2('destroy');
85+
});
86+
8187
document.addEventListener("turbolinks:load", function(e) {
8288
// Show the tab associated with the window location hash (e.g. "#packages")
8389
if (window.location.hash) {

0 commit comments

Comments
 (0)