81,092
社区成员
发帖
与我相关
我的任务
分享
<script>
var editor;
KindEditor.ready(function(K) {
var options = {
width : '1000px',
height : '900px',
uploadJson : 'editor/jsp/upload_json.jsp',
fileManagerJson : 'editor/jsp/file_manager_json.jsp',
allowFileManager : true,
afterBlur: function(){
this.sync();
}
}
var editor = K.create('#editor_id', options);
prettyPrint();
});
</script>
<textarea id="editor_id" name="content" style="width:700px;height:300px;">
</textarea>
KindEditor.ready(function(K) {
var editor = K.create('textarea[name="content1"]', {
cssPath : 'kindeditor/plugins/code/prettify.css',
uploadJson : 'kindeditor/asp/upload_json.asp',
fileManagerJson : 'kindeditor/asp/file_manager_json.asp',
allowFileManager : true,
afterBlur: function(){this.sync();}
});
prettyPrint();
$("#content").change(
function(){
$.post("as.asp",{act:"getcontent",id:$(this).val()},function(data){
editor.html(data);
});
});
});
上面这段代码是在<head>之前的。
下面这段是要调用数据的
$("#content").val(id);
$("#content").change();
原理是我先将要从后台获取数据的Id赋值到以content为Id的textarea,然后执行chang()来激活已经初始化的KindEditor.ready中的$("#content").change事件,在里面获取到所要的数据data并执行 ditor.html(data);并直接赋值显示。[/quote]
然而该方法并不好使,jquery的change方法不是内容改变之后才触发吗?
KindEditor.ready(function(K) {
var editor = K.create('textarea[name="content1"]', {
cssPath : 'kindeditor/plugins/code/prettify.css',
uploadJson : 'kindeditor/asp/upload_json.asp',
fileManagerJson : 'kindeditor/asp/file_manager_json.asp',
allowFileManager : true,
afterBlur: function(){this.sync();}
});
prettyPrint();
$("#content").change(
function(){
$.post("as.asp",{act:"getcontent",id:$(this).val()},function(data){
editor.html(data);
});
});
});
上面这段代码是在<head>之前的。
下面这段是要调用数据的
$("#content").val(id);
$("#content").change();
原理是我先将要从后台获取数据的Id赋值到以content为Id的textarea,然后执行chang()来激活已经初始化的KindEditor.ready中的$("#content").change事件,在里面获取到所要的数据data并执行 ditor.html(data);并直接赋值显示。