From 9df5838aa5bea2a7ea9dd709ab1f5f5938cb54e7 Mon Sep 17 00:00:00 2001 From: Jan Paul Posma Date: Sun, 27 Feb 2011 17:14:01 +0000 Subject: [PATCH] Fixes bug when having multiple textareas, which is caused by the fact that dialogs are kept in memory for performance, even when selecting a different textarea. --- modules/jquery.wikiEditor.dialogs.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/jquery.wikiEditor.dialogs.js b/modules/jquery.wikiEditor.dialogs.js index 036665c3..f416b4b6 100644 --- a/modules/jquery.wikiEditor.dialogs.js +++ b/modules/jquery.wikiEditor.dialogs.js @@ -84,7 +84,12 @@ fn: { } } } - if ( !filtered && $.wikiEditor.isSupported( module ) && $( '#' + module.id ).size() == 0 ) { + // If the dialog already exists, but for another textarea, simply remove it + var $existingDialog = $( '#' + module.id ); + if ( $existingDialog.size() > 0 && $existingDialog.data( 'context' ).$textarea != context.$textarea ) { + $existingDialog.remove(); + } + if ( !filtered && $.wikiEditor.isSupported( module ) && $existingDialog.size() == 0 ) { $.wikiEditor.modules.dialogs.modules[mod] = module; // If this dialog requires the iframe, set it up if ( typeof context.$iframe == 'undefined' && $.wikiEditor.isRequired( module, 'iframe' ) ) {