回复Roddy:罗老师,下面是我的案例。这样运行起来编辑器可以调用,也可以正常使用,然后上传图片不能正常使用。
index.html
<!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 type="text/javascript" src="Js/jquery.js"></script>
<script charset="UTF-8" src="kindeditor/kindeditor.js"></script>
<script charset="UTF-8" src="kindeditor/lang/zh_CN.js"></script>
</head>
<body>
<script>
/*调用编辑器*/
$(function(){
var editor = KindEditor.create('textarea[name="content"]');
});
/*编辑器上传调用*/
upPic("#upbtn","#thumb");
/*编辑器上传图片调用*/
function upPic(btnID,urlID){
KindEditor.ready(function(K) {
var editor = K.editor({
allowFileManager : true
});
K(btnID).click(function() {
editor.loadPlugin('image', function() {
editor.plugin.imageDialog({
imageUrl : K(urlID).val(),
clickFn : function(url, title, width, height, border, align) {
K(urlID).val(url);
editor.hideDialog();
editor.sync();
}
});
});
});
});
}
</script>
<input type="text" id="thumb" name="thumb" value="" class="comTxt" size="30" readonly="readonly"> <input type="button" name="upbtn" id="upbtn" class="comBtn" value="上传图片">
<textarea name="content" width="700"></textarea>
<a href="javascript:void(0)">点击此处Ajax加载上传图片部分</a>
</body>
</html>
<script>
$("a").click(function(){
$.ajax({
type: "GET",
url:"test.html",
success:function(data){
$("body").html(data);
}
});
});
</script>
text.html
<script>
/*调用编辑器*/
$(function(){
var editor = KindEditor.create('textarea[name="content"]');
});
/*编辑器上传调用*/
upPic("#upbtn","#thumb");
/*编辑器上传图片调用*/
function upPic(btnID,urlID){
KindEditor.ready(function(K) {
var editor = K.editor({
allowFileManager : true
});
K(btnID).click(function() {
editor.loadPlugin('image', function() {
editor.plugin.imageDialog({
imageUrl : K(urlID).val(),
clickFn : function(url, title, width, height, border, align) {
K(urlID).val(url);
editor.hideDialog();
editor.sync();
}
});
});
});
});
}
</script>
<input
type="text" id="thumb" name="thumb" value="" class="comTxt" size="30"
readonly="readonly"> <input type="button" name="upbtn"
id="upbtn" class="comBtn" value="上传图片">
<textarea name="content" width="700"></textarea>