我很困扰。
我创建了以下位于http://tapmeister.com/test/dom.html的脚本。由于某些未知原因,tinymce.editors.ta1 和 tinymce.editors[0] 显示为未定义,尝试使用它们下的方法会导致错误。但是当我使用 FireBug 检查 tinymce 或 tinymce.editors 时,我会在 DOM 中看到它们。
所以,我创建了一个 jsfiddle http://jsfiddle.net/JWyWM/来向 stackoverflow 上的人展示。但是当我测试它时,tinymce.editors.ta1 和 tinymce.editors[0] 不再是未定义的,并且这些方法可以正常工作。
到底是怎么回事???也许与公共/受保护/私有财产有关?如何访问诸如tinymce.editors.ta1.hide()
?谢谢!!!
<!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=ISO-8859-1" />
<title>Testing</title>
<script src="http://tinymce.cachefly.net/4.0/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({selector: "textarea#ta1"});
tinymce.init({selector: "textarea#ta2"});
console.log(tinymce);
console.log(tinymce.editors);
console.log(tinymce.editors.ta1);
console.log(tinymce.editors[0]);
//tinymce.editors.ta1.hide();
//alert('pause');
//tinymce.editors.ta1.show();
</script>
</head>
<body>
<form>
<textarea id="ta1"></textarea>
<textarea id="ta2"></textarea>
</form>
</body>
</html>