Temp fix for duplicate dom ids CRM-12188
authorColeman Watts <coleman@civicrm.org>
Sat, 23 Mar 2013 22:53:10 +0000 (15:53 -0700)
committerColeman Watts <coleman@civicrm.org>
Sat, 23 Mar 2013 22:53:10 +0000 (15:53 -0700)
js/crm.designerapp.js
js/view/crm.designer.js

index a229c4e4f677b2e4cc694724a9da16fca3519a3d..a3001ac7f1d69724ea98bb94e113690d47698fe3 100644 (file)
@@ -9,4 +9,23 @@ cj(document).ready(function($) {
    */
   CRM.designerApp = new Backbone.Marionette.Application();
 
+  /**
+   * FIXME: Workaround for problem that having more than one instance
+   * of a profile on the page will result in duplicate DOM ids.
+   * @see CRM-12188
+   */
+  CRM.designerApp.clearPreviewArea = function() {
+    $('.crm-profile-selector-preview-pane > .crm-form-block').each(function() {
+      var parent = $(this).parent();
+      CRM.designerApp.DetachedProfiles.push({
+        parent: parent,
+        item: $(this).detach()
+      });
+    });
+  };
+  CRM.designerApp.restorePreviewArea = function() {
+    $.each(CRM.designerApp.DetachedProfiles, function() {
+      $(this.parent).append(this.item);
+    });
+  };
 });
index ccc68b28717808115c9ccee570e023c082813a20..5ecfea62b38254dc15fd368bc8375aa1a408540b 100644 (file)
@@ -99,6 +99,8 @@
             });
           }
           designerDialog.undoState = false;
+          // CRM-12188
+          CRM.designerApp.DetachedProfiles = [];
         },
         close: function() {
           window.onbeforeunload = designerDialog.oldOnBeforeUnload;
               return false;
             });
           }
+          // CRM-12188
+          CRM.designerApp.restorePreviewArea();
         },
         resize: function() {
           CRM.designerApp.vent.trigger('resize');
       }
       var $dialog = this.$el.closest('.crm-designer-dialog'); // FIXME use events
       $dialog.block({message: 'Loading...', theme: true});
+      // CRM-12188
+      CRM.designerApp.clearPreviewArea();
       $.ajax({
         url: CRM.url("civicrm/ajax/inline"),
         type: 'POST',