Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Removing wymeditor from the DOM whilst cursor is in it causes new wymeditors to lose edit ability #354

Open
monkeydispenser opened this Issue May 25, 2012 · 1 comment

Comments

Projects
None yet
1 participant

I noticed this on a page I created which regularly adds/removes textareas and the associated wymeditor. On IE8 and IE9 if you remove the entire wymeditor structure from the DOM whilst the cursor is in it any newly created wymeditor loses the ability to edit the text. If the wymeditor does not have focus or if there is an actual selection in the wymeditor (i.e. non-collapsed range) the problem does not occur.

The problem does not occur in Chrome.

The only way to recover from the issue appears to be refreshing the page.

Example which can be used to recreate the issue:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
 * File Name:
 *        18-showhide-issue.html
 *        WYMeditor IE bug example.
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>WYMeditor</title>
<!-- jQuery library is required, see http://jquery.com/ -->
<script type="text/javascript" src="../jquery/jquery.js"></script>
<!-- WYMeditor main JS file, minified version -->
<script type="text/javascript" src="../wymeditor/jquery.wymeditor.min.js"></script>

<script type="text/javascript">

jQuery(function() {
    //handle show/hide event
    jQuery('.toggleEditorDisplay').click(function() {
        if (jQuery('.wymeditor').length > 0) {
            jQuery('#Editor').empty();
        } else {
            // Create the textarea and editor
            jQuery('#Editor').append('<textarea class="wymeditor">&lt;p&gt;Hello, World!&lt;/p&gt;</textarea>');
            jQuery('.wymeditor').wymeditor();
        }
    });

});

</script>

</head>

<body>
<h1>WYMeditor IE show/hide bug example</h1>
<p><a href="http://www.wymeditor.org/">WYMeditor</a> is a web-based XHTML WYSIWYM editor.</p>
<button class="toggleEditorDisplay">Toggle Visibility</button>
<div id="Editor"></div>
</body>

</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment