ckeditor的不加载上通过Ajax调用生成的元素? [英] ckeditor not loading on element generated via ajax call?
本文介绍了ckeditor的不加载上通过Ajax调用生成的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用自定义表单,并生成表单元素与AJAX调用,但textarea的是没装的CKEditor。这是我的code:
I am using custom form and generating form elements with ajax call but textarea is not loaded with ckeditor. Here is my code:
阿贾克斯code:
jQuery.ajax({
type: "POST",
url: "reg_arz_ajax2.php",
data: "book="+book_arzyabi,
dataType : "html",
success: function(response){
$('#resp').html(response);
},
error:function (xhr, ajaxOptions, thrownError){
//On error, we alert user
alert(thrownError);
}
});
$( "#dialog-form" ).dialog( "open");
});
Ajax响应是:
ajax response is:
'<textarea class="ckeditor" cols="80" id="fname" name="fname" rows="10" >test</textarea>';
HTML code:
html code:
<html>
<head>
<script type="text/javascript" src="../include/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="../include/ckeditor/sample.js" ></script>
</head>
<body>
<form>
<fieldset>
<label for="name">Name</label>
<div id="resp" ></div>
</fieldset>
</form>
</body>
</html>
请帮我解决问题。
推荐答案
将这些行:
ckeditor.replace('#fname'); // ADD THIS
$('#fname').ckeditor(); // ADD THIS
您code应该是这样的:
Your code should look like this:
jQuery.ajax({
type: "POST",
url: "reg_arz_ajax2.php",
data: "book="+book_arzyabi,
dataType : "html",
success: function(response){
$('#resp').html(response);
ckeditor.replace('#fname'); // ADD THIS
$('#fname').ckeditor(); // ADD THIS
},
error:function (xhr, ajaxOptions, thrownError){
//On error, we alert user
alert(thrownError);
}
});
$( "#dialog-form" ).dialog( "open");
});
这篇关于ckeditor的不加载上通过Ajax调用生成的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文