2

ここでリッチテキスト編集にImperaviRedactorコントロールを使用しようとしています。

<div class="control-group">
  <%= f.label :description %>
  <div class="controls">
    <%= f.text_area :description, :class => "richtext" %>
  </div>
</div>

$(document).ready(function(){
    $('.richtext').redactor();
});

リッチテキストエディタが表示され、正常に動作しますが、コンテンツを入力すると、GoogleChromeのInspectElementを使用して、HTMLマークアップが非表示のテキスト領域にコピーされていないことがわかります。見る:

<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を実行すると、テキストエリアが空白であるため、サーバーには明らかに何も表示されません。

リッチHTMLをテキストエリアにコピーする方法について何か提案はありますか?私は何が間違っているのですか?

4

1 に答える 1

3

組み込み関数を試してください$().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();
},
于 2013-02-04T00:10:58.997 に答える