Skip to content
Browse files

FLUID-4681: Further fixes to TinyMCE integration in the case multiple…

… instances are created per page. This caused failed registration of listeners since the 2nd instance has its markup created synchronously. Resolved a further issue where "globalDismissal" only kept one dismissal entry as a result of both registered containers supplying the same id "tinymce" created by the renderer within the iframe.
  • Loading branch information...
1 parent 53211c6 commit 735d25dd5f3e2f342677b4f2919d00d3d5838b8d @amb26 committed Mar 28, 2012
View
10 src/webapp/components/inlineEdit/js/InlineEditIntegrations.js
@@ -214,8 +214,14 @@ var fluid_1_5 = fluid_1_5 || {};
oldinit();
}
};
-
- tinyMCE.init(options);
+ // Ensure that instance creation is always asynchronous, to ensure that
+ // blurHandlerBinder always executes BEFORE instance is ready - so that
+ // its afterInitEdit listener is registered in time. All of this architecture
+ // is unsatisfactory, but can't be easily fixed until the whole component is
+ // migrated over to IoC with declarative listener registration.
+ setTimeout(function() {
+ tinyMCE.init(options);
+ }, 1);
};
fluid.defaults("fluid.inlineEdit.tinyMCE", {
View
16 src/webapp/demos/inlineEdit/rich/html/inlineEdit.html
@@ -53,6 +53,22 @@
<button class="demo-save">Save</button> <button class="demo-cancel">Cancel</button>
</div>
</div>
+
+ <h1>Duplicate Rich Text Inline Edit with Tiny MCE</h1>
+ <div id="demo-richInlineEdit-container-tinyMCE-2">
+ <div class="flc-inlineEdit-text">
+ <p>After a hiatus, <strong>Portishead</strong> is back with their first studio
+ album in 6 years. <em>Third</em> brings back the familiar and
+ the new, and none of this is best exemplified than in the track
+ <em>Machine Gun</em>. It seems that regardless of how <strong>Portishead</strong>
+ sounds now, the one thing that has stayed constant is their refusal to be ordinary.
+ </p>
+ </div>
+ <div class="flc-inlineEdit-editContainer">
+ <textarea></textarea>
+ <button class="demo-save">Save</button> <button class="demo-cancel">Cancel</button>
+ </div>
+ </div>
<!-- Inline Edit with CKEditor editor. -->
<h1>Rich Text Inline Edit with CKEditor 3</h1>
View
16 src/webapp/demos/inlineEdit/rich/js/inlineEditDemo.js
@@ -36,10 +36,9 @@ var demo = demo || {};
editor.cancel();
return false;
});
- };
-
- // Create a TinyMCE-based Rich Inline Edit component.
- var tinyEditor = fluid.inlineEdit.tinyMCE("#demo-richInlineEdit-container-tinyMCE", {
+ };
+
+ var tinyMCEOptions = {
tinyMCE: {
width: 1024,
theme: "advanced",
@@ -56,8 +55,15 @@ var demo = demo || {};
textEditButton: "Edit"
},
tooltipText: "Use the Edit link to make changes"
- });
+ };
+
+ // Create a TinyMCE-based Rich Inline Edit component.
+ var tinyEditor = fluid.inlineEdit.tinyMCE("#demo-richInlineEdit-container-tinyMCE", tinyMCEOptions);
makeButtons(tinyEditor);
+
+ // Create a TinyMCE-based Rich Inline Edit component.
+ var tinyEditor2 = fluid.inlineEdit.tinyMCE("#demo-richInlineEdit-container-tinyMCE-2", tinyMCEOptions);
+ makeButtons(tinyEditor2);
// Create an CKEditor 3.x-based Rich Inline Edit component.
var ckEditor = fluid.inlineEdit.CKEditor("#demo-richInlineEdit-container-ckEditor", {
View
6 src/webapp/framework/core/js/FluidView.js
@@ -414,8 +414,10 @@ var fluid_1_5 = fluid_1_5 || {};
*/
fluid.globalDismissal = function (nodes, dismissFunc) {
fluid.each(nodes, function (node) {
- node = $(node);
- var id = fluid.allocateSimpleId(node);
+ // Don't bother to use the real id if it is from a foreign document - we will never receive events
+ // from it directly in any case - and foreign documents may be under the control of malign fiends
+ // such as tinyMCE who allocate the same id to everything
+ var id = node.ownerDocument === document? fluid.allocateSimpleId(node) : fluid.allocateGuid();
if (dismissFunc) {
dismissList[id] = dismissFunc;
}

0 comments on commit 735d25d

Please sign in to comment.
Something went wrong with that request. Please try again.