Skip to content

Commit 1077122

Browse files
authored
Merge branch 'master' into chore/remove-jquery
2 parents 3415a8e + 883d077 commit 1077122

File tree

1 file changed

+7
-12
lines changed
  • djangocms_versioning/static/djangocms_versioning/js

1 file changed

+7
-12
lines changed

djangocms_versioning/static/djangocms_versioning/js/compare.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,16 @@ function bindHandlers(submitButton) {
66
}
77

88
window.addEventListener('load', function() {
9-
document.querySelector('select[name=action]').addEventListener('change', function() {
10-
// Always set handlersBound to false when the select option changed
11-
let handlersBound = false;
12-
let selectVal = this.options[this.selectedIndex].getAttribute('value');
13-
const actionsForm = document.getElementById('changelist-form');
14-
const submitButton = actionsForm.querySelector('[type="submit"]');
9+
document.querySelector('select[name=action]').addEventListener('change', function() {
10+
let selectVal = this.options[this.selectedIndex].getAttribute("value");
11+
const actionsForm = document.getElementById('changelist-form')
12+
const submitButton = actionsForm.querySelector('[type="submit"]')
1513

1614
if (selectVal === 'compare_versions') {
1715
// Setting the target to blank to ensure the compare view is opened in a new tab
18-
actionsForm.setAttribute('target', '_blank');
19-
if (handlersBound === false) {
20-
bindHandlers(submitButton);
21-
handlersBound = true;
22-
}
23-
} else {
16+
actionsForm.setAttribute('target', '_blank');
17+
bindHandlers(submitButton);
18+
}else {
2419
// If the user deselect the compare version action, the "target=_blank" is removed
2520
actionsForm.removeAttribute('target');
2621
}

0 commit comments

Comments
 (0)