From 4151fff2b82b6c505989ab59691010fab7cfec6a Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 23 Mar 2013 15:53:10 -0700 Subject: [PATCH] Temp fix for duplicate dom ids CRM-12188 --- js/crm.designerapp.js | 19 +++++++++++++++++++ js/view/crm.designer.js | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/js/crm.designerapp.js b/js/crm.designerapp.js index a229c4e4f6..a3001ac7f1 100644 --- a/js/crm.designerapp.js +++ b/js/crm.designerapp.js @@ -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); + }); + }; }); diff --git a/js/view/crm.designer.js b/js/view/crm.designer.js index ccc68b2871..5ecfea62b3 100644 --- a/js/view/crm.designer.js +++ b/js/view/crm.designer.js @@ -99,6 +99,8 @@ }); } designerDialog.undoState = false; + // CRM-12188 + CRM.designerApp.DetachedProfiles = []; }, close: function() { window.onbeforeunload = designerDialog.oldOnBeforeUnload; @@ -113,6 +115,8 @@ return false; }); } + // CRM-12188 + CRM.designerApp.restorePreviewArea(); }, resize: function() { CRM.designerApp.vent.trigger('resize'); @@ -241,6 +245,8 @@ } 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', -- 2.25.1