gpt4 book ai didi

javascript - bootstrap wysihtml5 设置值不起作用

转载 作者:行者123 更新时间:2023-11-29 10:29:22 25 4
gpt4 key购买 nike

我有一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com