一旦调用 CKeditor 实例,Javascript 就无法更改文本区域中的文本
好吧,我首先编写了一个 JavaScript 函数,它会根据您在下拉框中所做的选择来更改 textarea
中的文本,这是一件非常简单的事情。
HTML
<form name="formconteudo">
<select name="selectpage" onChange="change();">
<option value="1">something</option>
<option value="2">another thing</option>
<option value="3">going crazy</option>
</select>
</form>
JS
var Code = new Array("", "Selected 1", "Selected 2", "Selected 3");
function change()
{
var ID = formconteudo.selectpage.options[formconteudo.selectpage.selectedIndex].value;
document.formconteudo.ckeditor.value = Code[ID];
}
这非常有效,并且更改了文本区域中的文本。但后来我在该文本区域上调用了 CKeditor 实例,以便我可以在该文本区域上使用 CKEditor。编辑器加载良好且运行良好。但现在 JavaScript 不工作了。
有关问题的任何提示吗?
谢谢
Well i first wrote a Javascrip function that would change the text in a textarea
according to the selection you made in a dropdown box, a really simple thing.
HTML
<form name="formconteudo">
<select name="selectpage" onChange="change();">
<option value="1">something</option>
<option value="2">another thing</option>
<option value="3">going crazy</option>
</select>
</form>
JS
var Code = new Array("", "Selected 1", "Selected 2", "Selected 3");
function change()
{
var ID = formconteudo.selectpage.options[formconteudo.selectpage.selectedIndex].value;
document.formconteudo.ckeditor.value = Code[ID];
}
This worked pretty good and changed the text in the textarea. But then i called a CKeditor Instance on that textarea, so that i can use the CKEditor on that textarea. The Editor loads well and works great. But now the javascript isn't working.
Any hint on the problem?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将需要在编辑器上使用
setData
方法。这里是他们文档中的示例。
这意味着您的代码将如下所示:
注意
instances.editor1
可能不会引用您的框,因此请务必使用正确的名称You are going to want to use the
setData
method on the editor.Here is the example from their docs.
Which means your code will look something like this:
Note
instances.editor1
may not refer to your box, so be sure to use the right name我在这个问题上花了几天时间,每个人都不断给我奇怪的解决方案。检查了他们的API,它甚至还给出了一个例子。
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor .html#setData
其中
'YOUREDITORID'
是CKeditor要使用的文本区域的ID。希望这有帮助!
I've spent days on this issue, every one kept giving me odd solutions. Checked their API, and it even gives an example.
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#setData
Where
'YOUREDITORID'
is the ID of the textarea for CKeditor to be used.Hope this helps!