javascript - 从 SCEditor 获取值

标签 javascript jquery ajax sceditor

我正在尝试使用以下代码从我的 SCEditor textarea 中获取值:

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 只是空的。我做错了什么吗?

最佳答案

这对我有用:

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

关于javascript - 从 SCEditor 获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32364070/

相关文章:

javascript - JQuery 可调整大小 : How to make multiples divs resizing independently

javascript - 无法访问复制到剪贴板的文本

jquery - Asmx Web 服务返回 xml 而不是 json,尝试从服务输出中删除 <string xmlns ="http://tempuri.org/">

php - 我想在 WordPress 中使用用户名、电子邮件 ID 和电话号码登录

javascript - Ajax不会调用Codeigniter Controller 的方法

javascript - 如何通过ajax接收、发送和存储json数组

javascript - jquery 在图像中淡入淡出

javascript - 如果我在特定的 div 中,如何让 jQuery 启动?

javascript - 按角色/权限为用户授权 React 组件

javascript - react : How to pass array of ids to method