Prevents component from rerendering when Select2 is initialized

This commit is contained in:
Vlad
2018-01-31 17:48:17 -05:00
parent fef8017134
commit a0667adace

View File

@@ -44,6 +44,7 @@ define([
destroySelect2: function () { destroySelect2: function () {
if (this.isSelect2Initialized()) { if (this.isSelect2Initialized()) {
jQuery(`#${this.refs.select.id}`).select2('destroy'); jQuery(`#${this.refs.select.id}`).select2('destroy');
this.state.select2 = false;
} }
}, },
setupSelect2: function () { setupSelect2: function () {
@@ -110,7 +111,7 @@ define([
select2.on('change', this.handleChange); select2.on('change', this.handleChange);
this.setState({ select2: true }); this.state.select2 = true;
}, },
getSelectedValues: function () { getSelectedValues: function () {
if (this.props.field.selected !== undefined) { if (this.props.field.selected !== undefined) {