Check if select2 input exists before destroy

Avoiding TypeError of accessing property ‘data’ on an undefined error.
This error occurs when destroying an editable with input type select2
before the select2 has been created.
This commit is contained in:
powellzer 2015-01-29 12:05:42 -05:00
parent f32802f48a
commit 804f4f5521

@ -294,9 +294,11 @@ $(function(){
},
destroy: function() {
if(this.$input.data('select2')) {
this.$input.select2('destroy');
}
if(this.$input) {
if(this.$input.data('select2')) {
this.$input.select2('destroy');
}
}
}
});