From 256bca8ed971ea46a55e4caa45f6fe44ccf9405e Mon Sep 17 00:00:00 2001 From: Jonathan Labreuille Date: Tue, 26 Apr 2016 12:19:39 +0200 Subject: [PATCH] Fix selection.jsx by adding a check before trying to destroy the select2 instance --- assets/js/src/form/fields/selection.jsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/assets/js/src/form/fields/selection.jsx b/assets/js/src/form/fields/selection.jsx index 04f01a2e39..62abc180e0 100644 --- a/assets/js/src/form/fields/selection.jsx +++ b/assets/js/src/form/fields/selection.jsx @@ -33,6 +33,14 @@ function( } }, componentWillUnmount: function() { + if( + !this.props.field.multiple + || this.state.initialized === false + || this.refs.select === undefined + ) { + return; + } + jQuery('#'+this.refs.select.id).select2('destroy'); }, setupSelect2: function() {