主题: 在一个页面添加了两个Kindeditor,取值只有取到第二个,我的代码哪里有错? |
作者: 海纳百川, 发布日期: 2012-03-04 23:43:26, 浏览数: 4109 |
第一个接触Kindeditor,自己做了个小测试。 <!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" /> <title>无标题文档</title> <script charset="utf-8" src="editor/kindeditor.js"></script> <script charset="utf-8" src="editor/lang/zh_CN.js"></script> <script charset="utf-8" src="js/jquery.js"></script> <script> var editor; KindEditor.ready(function(K) { editor = K.create('#content_1', { resizeType : 1, allowPreviewEmoticons : false, allowImageUpload : false, items : [ 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|', 'emoticons', 'image', 'link'] }); editor = K.create('#content_2'); }); </script> </head> <body> <textarea id="content_1" name="content" style="width:700px;height:300px;">HTML内容</textarea> <button onclick="showMess1()">提交信息一</button> <textarea id="content_2" name="content" style="width:700px;height:300px;">HTML内容</textarea> <button onclick="showMess2()">提交信息二</button> <span id="showMess1">没有动作</span> <span id="showMess2">没有动作</span> <script type="text/javascript"> function showMess1(){ editor.sync(); $content_1 = $('#content_1').val(); $("#showMess1").ajaxStart(function(){ }); $('#showMess1').ajaxComplete(function(){ }); $.get("show.php", function(result){ $("#showMess1").html($content_1); }); } function showMess2(){ editor.sync(); $content_2 = $('#content_2').val(); $("#showMess2").ajaxStart(function(){ }); $('#showMess2').ajaxComplete(function(){ }); $.get("show.php", function(result){ $("#showMess2").html($content_2); }); } </script> </body> </html> |
作者: Roddy, 发布日期: 2012-03-05 00:07:57 |
实例都用一个editor当然有问题啦,分开放在不同的变量里就可以,比如,editor1,editor2
|
回复 |
作者: 海纳百川, 发布日期: 2012-03-05 20:23:51 |
人这两天在外面,懒得下测试环境了。 <script> var editor; KindEditor.ready(function(K) { editor = K.create('#content_1', { resizeType : 1, allowPreviewEmoticons : false, allowImageUpload : false, items : [ 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|', 'emoticons', 'image', 'link'] }); editor = K.create('#content_2'); }); </script>这样写: <script> var editor_1; KindEditor.ready(function(K) { editor_1 = K.create('#content_1', { resizeType : 1, allowPreviewEmoticons : false, allowImageUpload : false, items : [ 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|', 'emoticons', 'image', 'link'] }); }); var editor_2; KindEditor.ready(function(K) { editor_2 = K.create('#content_2'); }); </script> |
回复 |