0
我試圖找出幾個小時這段代碼有什麼問題。雙擊CKEditor正確打開後,按下正確的隱藏按鈕後。但在再次點擊div後,它不想再次打開,然後螢火蟲在ckeditor.js的第86行中返回一個錯誤「p爲null」。CKEditor選項startupMode導致js錯誤
最後事實證明,當我關閉選項「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>