0

几个小时以来,我一直试图找出这段代码有什么问题。双击 div 后 CKEditor 正确打开并按下按钮后正确隐藏。但是在再次单击 div 后,它不想再次打开,然后 firebug在 ckeditor.js 的第 86 行返回错误“p is null”

最后,当我关闭选项"startupMode: 'source'"时,问题消失了。有谁知道这种行为是由什么引起的?这是 CKEditor 中的错误还是我做错了什么。我使用的 CKEditor 版本是 3.6.4。提前感谢您的帮助!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="js/admin/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>

<body>
<h2>Vars</h2> 

<table>
    <tbody>
        <tr>
            <td>Cell no 1.1</td>
            <td><div class="editable" id="cell1">Cell no 1.2</div></td>
        </tr>
        <tr>
            <td>Cell no 2.1</td>
            <td><div class="editable" id="cell2">Cell no 2.2</div></td>
        </tr>
    </tbody>
</table>
<input type="submit" id="submit" value="Close"/>

<script type="text/javascript">

editor = false; 

function destroy_cke() {
    if (editor) {
        editor.updateElement();
        editor.destroy();
    }
}

function replace_div(div) {
    destroy_cke();
    editor = CKEDITOR.replace(div,{
        startupMode: 'source',
    });
}
$(document).ready (function() { 
    $('.editable').dblclick(function(e) {
        e.stopPropagation();
        var element = e.target || e.srcElement;
        while (element.nodeName.toLowerCase() != 'html' && (element.nodeName.toLowerCase() != 'div' || element.className.indexOf('editable') == -1 )) element = element.parentNode;
        replace_div(element);
    });

    $('#submit').click(function(){
        destroy_cke();
    });
});
</script>
</body>
</html>
4

1 回答 1

0

在http://cksource.com/forums/viewtopic.php?f=11&t=26734&p=67792#p67792回答

destroy_cke函数没有清除editor变量。

于 2012-08-04T09:44:14.433 回答