Imperavi Redactor content not being copied over to hidden textarea

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(); });

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>

When doing a form POST of this textarea nothing is visible to the server obviously, because the textarea is blank.

Any suggestions on how to have the rich html copied over to the textarea? What am I doing wrong?

Answer1:

Try build-in function $().syncCode()

syncCode: function() { var html = this.formatting(this.$editor.html()); this.$el.val(html); }

Or $().setCode()

setCode: function(html) { html = this.preformater(html); this.$editor.html(html).focus(); this.syncCode(); },

人吐槽 人点赞

Recommend

Comment

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:Imperavi Redactor content not being copied over to hidden textarea