function showEdit(){ var editor; KindEditor.ready(function(K) { editor = K.create('textarea[name="content"]', { allowPreviewEmoticons : false, allowImageUpload : false, allowFlashUpload : false, newlineTag : 'br', pasteType : 1, items : [ 'source','plainpaste', 'wordpaste' , '|','fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'table' , '|', 'emoticons', 'image', 'flash', 'link' , 'map' , 'clearhtml', 'about'] }); }); return editor; }
然后我在页面用
<script>var e = showEdit();e.html('test');</script>
编辑器可以加载出来 为什么e.html('test'); 没用呢
以前用3.5 的时候没啥问题,换了4 后 就得不到editor了
<script type="text/javascript">
showEdit();
editor.html('test');
</script >
引用来自“鲍平”的答案
<script type="text/javascript">
showEdit();
editor.html('test');
</script >
我是这样的:
先 :
<script>
var editor;
var options = {
width : '744px',
height : '504px',
filterMode : false
};
KindEditor.ready(function(K) {
editor = K.create('#editor_id',options);
});
</script>
后面
<script type="text/javascript">
$(document).ready(function(){
$('#save_mail').click(function(){
html = editor.html();
alert(html);
})
})
</script>
看我的
test.html
var
editor; 作为全局变量
引用来自“pyawen”的答案
var
editor; 作为全局变量
cooc123 回答于 2012-02-08 14:09 (27分钟前) 是全局的
1楼的现在吧 editor 改成全局的了
引用来自“cooc123”的答案
看我的
test.html
KindEditor.ready(function(K) {
});
这个方法 初始化完成后加载编辑器 类似于 $(document).ready()的东东
editor.insertHtml('ccccc'); 调用这个方法的时候 编辑器还没有初始化完成