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' ) ) {