Skip to content

Commit

Permalink
Only destroy select2 element if initialized (#486 #465 #426)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgonggrijp committed Jul 29, 2021
1 parent 1864a43 commit 15d6a58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions frontend/src/forms/select2-picker-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import BasePicker from './base-picker-view';
*/
export default class Select2PickerView extends BasePicker {
beforeRender(): this {
this.$('select').select2('destroy');
this.destroySelect();
return this;
}

Expand All @@ -16,8 +16,15 @@ export default class Select2PickerView extends BasePicker {
return this;
}

destroySelect(): void {
const select = this.$('select');
if (select.hasClass('select2-hidden-accessible')) {
select.select2('destroy');
}
}

remove(): this {
this.$('select').select2('destroy');
this.destroySelect();
return super.remove();
}

Expand Down
1 change: 1 addition & 0 deletions frontend/src/semantic-search/dropdown-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,5 @@ extend(Dropdown.prototype, {
val: BasePicker.prototype.val,
open: Select2Picker.prototype.open,
beforeRender: Select2Picker.prototype.beforeRender,
destroySelect: Select2Picker.prototype.destroySelect,
});

0 comments on commit 15d6a58

Please sign in to comment.