从 jQuery AJAX 请求返回时的 nicEdit 行为
我正在使用 nicEdit 将富文本编辑添加到文本区域。我使用 Codeigniter MVC 框架和 jQuery 进行简单的 AJAX 调用来创建一个新的文本区域,然后在从 AJAX 调用返回后将 nicEdit 应用于这个新的文本区域。一切都按预期工作,并且使用以下代码按预期实例化 nicEdit:
<html>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="<? echo base_url();?>assets/js/nicEdit.js"></script>
<body>
<div id="area1"></div>
<input id="submit" type="submit" value="submit" />
<script>
$(document).ready(function() {
$('#submit').click(function(){
$.ajax
({
type: "POST",
url: "test/ajax",
success: function(html)
{
$('#area1').html(html);
new nicEditor().panelInstance('newArea');
}
});
});
});
</script>
</body>
</html>
从提交按钮单击事件调用的 test/ajax 控制器是一个返回新文本区域的函数,如下所示:
function ajax()
{
echo "<textarea id='newArea'></textarea>";
}
在我的主应用程序中,我在概念上执行与上面描述的相同,即从 AJAX 调用返回一个新的文本区域,然后在 AJAX 成功函数上实例化这个新区域。我遇到的问题是,虽然 nicEdit 通过 AJAX 调用连接到这个新的文本区域,但 nicEdit 图标没有出现。字体格式、字体系列和字体大小属性会显示并起作用,但不会显示其他图标(粗体、斜体、下划线等)。
欢迎提出建议。
I am using nicEdit to add rich text editing to a textarea. I am using the Codeigniter MVC framework and jQuery to make a simple AJAX call to create a new textarea then applying nicEdit to this new textarea once it's returned from the AJAX call. Everything works as expected and the nicEdit is instantiated as expected using the following code:
<html>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="<? echo base_url();?>assets/js/nicEdit.js"></script>
<body>
<div id="area1"></div>
<input id="submit" type="submit" value="submit" />
<script>
$(document).ready(function() {
$('#submit').click(function(){
$.ajax
({
type: "POST",
url: "test/ajax",
success: function(html)
{
$('#area1').html(html);
new nicEditor().panelInstance('newArea');
}
});
});
});
</script>
</body>
</html>
The test/ajax controller being called from the submit button click event is a function that returns a new textarea as follows:
function ajax()
{
echo "<textarea id='newArea'></textarea>";
}
In my main application, I am conceptually doing the same thing as described above, namely returning a new textarea from an AJAX call, then instantiating this new area on the AJAX success function. The problem I am having is that although nicEdit hooks onto this new textarea from the AJAX call, the nicEdit icons do not appear. The font format, font family and font size attributes are displayed and work, but none of the other icons (bold, italic, underline, etc.) are displayed.
Suggestions are appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您需要明确指定图标文件所在的位置。您可以在实例化 nicEditor 对象时传递配置字典来执行此操作: NicEdit 配置选项
I think you need to explicity specify where the icons file is located. You can do this passing a configuration dictionary when instantiating the nicEditor object: NicEdit Configuration Options