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