2

次のコードを使用して、SCEditor テキストエリアから値を取得しようとしています。

var fbeschreibung = '';
$(function() {
    // Replace all textarea's
    // with SCEditor
    $("textarea").sceditor({
        plugins: "bbcode",
        style: "css/style.less",
        width: "100%",
        toolbar:"bold,italic,underline,strike,subscript,superscript|left,center,right,justify|size,color,removeformat|bulletlist,orderedlist,horizontalrule,emoticon",
        locale:"de" ,
        resizeEnabled:false
    });
    fbeschreibung = $('textarea').sceditor('instance').val();
    $('textarea').sceditor('instance').val('Hello [b]World![/b]');
});

次に、AJAX 経由で値を送信します。

$.post('saveprofile.php', 
   {fbeschreibung : fbeschreibung},
   function (response) {
      alert(response);
   }
);

しかし、私はこれを機能させることができません。ドキュメントにヒントが見つかりませんでした:http://www.sceditor.com/api/sceditor/val/

私の変数fbeschreibungは空です。私が何か間違ったことはありますか?

4

3 に答える 3

5

これは私のために働いた:

$(function() {
    // Replace all textarea's
    // with SCEditor
    var fbeschreibung = $("textarea").sceditor({
        plugins: "bbcode",
        style: "css/style.less",
        width: "100%",
        toolbar:"bold,italic,underline,strike,subscript,superscript|left,center,right,justify|size,color,removeformat|bulletlist,orderedlist,horizontalrule,emoticon",
        locale:"de" ,
        resizeEnabled:false
    }).sceditor('instance');
    var value = fbeschreibung.getBody().html();
});
于 2015-10-05T12:17:42.107 に答える
1

私はこの特定のエディターに精通していませんが、提供したオプション (コメント) が機能する可能性があります。

var fbeschreibung = '';
$(function() {
    // Replace all textarea's
    // with SCEditor
    var editor = $("textarea").sceditor({
        plugins: "bbcode",
        style: "css/style.less",
        width: "100%",
        toolbar:"bold,italic,underline,strike,subscript,superscript|left,center,right,justify|size,color,removeformat|bulletlist,orderedlist,horizontalrule,emoticon",
        locale:"de" ,
        resizeEnabled:false
    });
    /* Try the following 3 options */

    fbeschreibung = editor.val();
    fbeschreibung = editor.getSourceEditorValue();
    fbeschreibung = editor.getWysiwygEditorValue();

    editor.val('Hello [b]World![/b]');
});
于 2015-09-02T22:35:19.650 に答える