weixin_33701617 2015-09-02 22:18 采纳率: 0%
浏览 38

从SCEditor获取值

I'm trying to get the value from my SCEditor textarea, using this code:

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]');
});

I then want to send the value via AJAX:

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

However, I'm not able to get this to work. I haven't found find any tips in the documentation: http://www.sceditor.com/api/sceditor/val/

My variable fbeschreibung is just empty. Is there something I've done wrong?

  • 写回答

3条回答 默认 最新

  • weixin_33701294 2015-09-02 22:35
    关注

    I am not familiar with this particular editor, but the options (comments) I provided you may work.

    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]');
    });
    
    评论

报告相同问题?