1

asp mvc サイトで YUI リッチ テキスト エディターを使用しようとしています。この JavaScript コードを使用しています。

var myEditor = new YAHOO.widget.Editor('Body', {
    height: '300px',
    width: '522px',
    dompath: true, //Turns on the bar at the bottom
    animate: true //Animates the opening, closing and moving of Editor windows
});
myEditor.render();

``

このテキストエリアで

<div class="yui-skin-sam">
            @Html.TextAreaFor(model => model.Body, new { cols = "50", rows = 10 })
            @Html.ValidationMessageFor(model => model.Body)
        </div>

エディターがロードされますが、フォームを送信したときにその内容が渡されません。何も入力されていない場合はフィールドが必要であるという検証メッセージが表示され続けます。

これを私が望むように機能させる方法を知っている人はいますか?

4

1 に答える 1

0

他の誰かがこの問題に遭遇した場合の解決策は次のとおりです。

このように handleSubmit:true を設定してみることができます

var myEditor = new YAHOO.widget.Editor('Body', {
height: '300px',
width: '522px',
dompath: true, //Turns on the bar at the bottom
animate: true, //Animates the opening, closing and moving of Editor windows
handleSubmit: true

}); myEditor.render();

エディターはそれ自体をアタッチしようとし、コンテンツをテキストエリアに戻す myEditor.saveHTML() を自動的に呼び出します。それが私の場合のように失敗した場合は、以下のようなイベントを設定して手動で実行してください。

   YAHOO.util.Event.on('somebutton', 'click', function() {

myEditor.saveHTML();
alert("test");
});

somebutton は、フォームの送信ボタンの名前です。

これが機能するようになると、2 つ目の問題は、モデル内で html タグを見つけると asp.net がエラーになることです。これは別の問題なので、ここでは解決策を説明しません。

于 2012-04-12T01:47:27.363 に答える