Hi,

PFA patch for select2 controls.

Change: Destroy existing any select2 controls before re-rendering them.
Otherwise this was causing wired dialogue UI hang issue.

-- 
*Harshal Dhumal*
*Software Engineer *



EenterpriseDB <http://www.enterprisedb.com>
diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js
index de30e48..8bf71dc 100644
--- a/web/pgadmin/browser/static/js/node.ui.js
+++ b/web/pgadmin/browser/static/js/node.ui.js
@@ -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;
     }
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 201ecc1..d55007d 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1782,6 +1782,9 @@
    */
   var Select2Control = Backform.Select2Control = Backform.SelectControl.extend({
     render: function() {
+      if(this.$sel && this.$sel.select2) {
+        this.$sel.select2('destroy')
+      }
       Backform.SelectControl.prototype.render.apply(this, arguments);
 
       var opts = this.field.toJSON();
@@ -1795,7 +1798,7 @@
        */
       var $select = this.$el.find("select");
       $select.prepend($('<option></option>'));
-      $select.select2(select2Opts);
+      this.$sel = $select.select2(select2Opts);
 
       return this;
     }
-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to