Skip to content

Commit

Permalink
fix #122: Reset of Selectize with static options
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed Mar 26, 2024
1 parent a88a373 commit bde4b42
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions client/django-formset/DjangoSelectize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,19 @@ export class DjangoSelectize extends IncompleteSelect {
protected async reloadOptions(silent?: boolean) {
const currentValue = this.getValue();
this.tomSelect.clear(true);
this.tomSelect.clearOptions();
this.tomInput.replaceChildren();
this.fieldGroup.classList.remove('dj-dirty', 'dj-touched', 'dj-validated');
this.fieldGroup.classList.add('dj-untouched', 'dj-pristine');
const errorPlaceholder = this.fieldGroup.querySelector('.dj-errorlist > .dj-placeholder');
if (errorPlaceholder) {
errorPlaceholder.innerHTML = '';
}
await this.loadOptions(this.buildFetchQuery(0), (options: Array<OptionData>) => {
this.tomSelect.addOptions(options);
});
if (this.isIncomplete) {
this.tomSelect.clearOptions();
this.tomInput.replaceChildren();
await this.loadOptions(this.buildFetchQuery(0), (options: Array<OptionData>) => {
this.tomSelect.addOptions(options);
});
}
this.tomSelect.setValue(currentValue, silent);
}

Expand Down

0 comments on commit bde4b42

Please sign in to comment.