Imperavi Redactor内容未复制到隐藏的文本区域 [英] Imperavi Redactor content not being copied over to hidden textarea
问题描述
我正在尝试使用 Imperavi Redactor 控件在此处进行富文本
I'm trying to use the Imperavi Redactor control for my rich text editing here:
<div class="control-group">
<%= f.label :description %>
<div class="controls">
<%= f.text_area :description, :class => "richtext" %>
</div>
</div>
$(document).ready(function(){
$('.richtext').redactor();
});
富文本编辑器出现并可以正常工作,但是,当我输入内容时,我可以看到使用Google Chrome中的Inspect元素时html标记没有被复制到隐藏文本区域.参见:
The rich text editor appears and works fine, however when I type in content, I can see using the Inspect Element in Google Chrome that the html markup is not being copied over to the hidden text area. See:
<div class="controls">
//Removed toolbar for brevity.
<div class="redactor_box">
<div class="redactor_richtext redactor_editor" contenteditable="true" dir="ltr"><p>asdfjoiasjdf</p><p>dfjiasdfjiasd</p><p>idsfj</p><p>asdffaas</p></div>
</div>
<textarea class="richtext" cols="40" id="program_description" name="program[description]" rows="20" style="display: none;"></textarea></div>
</div>
在执行此文本区域的表单POST时,服务器显然看不到任何内容,因为文本区域为空白.
When doing a form POST of this textarea nothing is visible to the server obviously, because the textarea is blank.
关于如何将丰富的html复制到textarea的任何建议?我在做什么错了?
Any suggestions on how to have the rich html copied over to the textarea? What am I doing wrong?
推荐答案
尝试使用内置函数$().syncCode()
syncCode: function()
{
var html = this.formatting(this.$editor.html());
this.$el.val(html);
}
或$().setCode()
setCode: function(html)
{
html = this.preformater(html);
this.$editor.html(html).focus();
this.syncCode();
},
这篇关于Imperavi Redactor内容未复制到隐藏的文本区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!