javascript - bootstrap wysihtml5 设置值不起作用

标签 javascript jquery asp.net wysihtml5 bootstrap-wysiwyg

我有一个 wysihtml 框,我想在 ajax 调用后填充它的值

$("#<%=txtDescrizioneBreveCategoria.ClientID%>").wysihtml5();

function ModificaCategoria(id) {
    $.ajax({
                url: "Categorie.aspx/GetCategoria",
                type: 'POST',
                dataType: "json",
                data: JSON.stringify({ 'id': id }),
                contentType: 'application/json; charset=utf-8',
                cache: false,
                async: false,
                processdata: true,
                traditional: true,
                success: function (data) {
                    var c = data.d;
                        //we need to parse it to JSON 
                        c = $.parseJSON(c);
                        $('#<%=txtTitleCategoria.ClientID%>').val(c.Title);
                        $('#<%=txtDescrizioneBreveCategoria.ClientID%>').val(c.Descrizione);
                }
        });
}

我已经尝试过

$('#<%=txtDescrizioneBreveCategoria.ClientID%>').contents().find('body').html('<b>New text</a>');

$('#<%=txtDescrizioneBreveCategoria.ClientID%>').html(c.Descrizione);

var editorObj = $("#<%=txtDescrizioneBreveCategoria.ClientID%>").data('wysihtml5');
var editor = editorObj.editor;
editor.setValue(c.DescrizioneBreve);

但编辑器变量始终未定义 我正在使用 wysihtml5x v0.4.15 链接here

最佳答案

你应该能够使用下面的方法实现同样的效果

$("#<%=txtDescrizioneBreveCategoria.ClientID%>").wysihtml5();
window.describeEditor = window.editor;

然后你应该可以使用

describeEditor.setValue(c.DescrizioneBreve, true)

或使用

editorDescrizioneBreve.data("wysihtml5").editor.setValue(c.DescrizioneBreve, true);

在哪里editorDescrizioneBreve$("#<%=txtDescrizioneBreveCategoria.ClientID%>").wysihtml5() 返回的对象

PS:解决方案基于https://github.com/jhollingworth/bootstrap-wysihtml5/issues/52

关于javascript - bootstrap wysihtml5 设置值不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50159344/

相关文章:

javascript - 将函数设置为已弃用

PHP 表单使用动态输入插入数据数组

c# - ASP.net Identity v2.0.0 电子邮件确认/重置密码错误

php - MySQLi 和 Phalanger

asp.net - 从 asp.net mvc Controller 操作获取查询字符串的值 &lt;script type ="text/javascript">

javascript - 如何将网页的所有链接转换为短网址?

jquery - html 中文本跨度超过 max-width

jquery - 使用 jQuery 将 CSS 文件内容导出到 TEXTAREA

javascript - 使用 jquery 访问 Asp.net 控件(所有选项)

javascript - jQuery-JSONP 插件放置在目录中时失败