Destroy the existing Select2 object before rerendering the control.

This commit is contained in:
Harshal Dhumal
2016-05-12 16:14:01 +05:30
committed by Ashesh Vashi
parent d768faf2ea
commit 585daddce2
2 changed files with 10 additions and 2 deletions

View File

@@ -142,6 +142,11 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) {
}
},
render: function() {
if(this.$sel && this.$sel.select2) {
this.$sel.select2('destroy')
}
/*
* Let SelectControl render it, we will do our magic on the
* select control in it.
@@ -167,7 +172,7 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) {
* Add empty option as Select2 requires any empty '<option><option>' for
* some of its functionality to work and initialize select2 control.
*/
this.$el.find("select").select2(select2_opts);
this.$sel = this.$el.find("select").select2(select2_opts);
return this;
}