Mar*_*ina 5 javascript asp.net jquery 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);
}
});
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试过
$('#<%=txtDescrizioneBreveCategoria.ClientID%>').contents().find('body').html('<b>New text</a>');
Run Code Online (Sandbox Code Playgroud)
与
$('#<%=txtDescrizioneBreveCategoria.ClientID%>').html(c.Descrizione);
Run Code Online (Sandbox Code Playgroud)
与
var editorObj = $("#<%=txtDescrizioneBreveCategoria.ClientID%>").data('wysihtml5');
var editor = editorObj.editor;
editor.setValue(c.DescrizioneBreve);
Run Code Online (Sandbox Code Playgroud)
但编辑器变量始终未定义我在这里使用 wysihtml5x v0.4.15 链接
您应该能够使用下面的方法实现相同的效果
$("#<%=txtDescrizioneBreveCategoria.ClientID%>").wysihtml5();
window.describeEditor = window.editor;
Run Code Online (Sandbox Code Playgroud)
然后你应该可以使用
describeEditor.setValue(c.DescrizioneBreve, true)
Run Code Online (Sandbox Code Playgroud)
或使用
editorDescrizioneBreve.data("wysihtml5").editor.setValue(c.DescrizioneBreve, true);
Run Code Online (Sandbox Code Playgroud)
editorDescrizioneBreve返回的对象在哪里$("#<%=txtDescrizioneBreveCategoria.ClientID%>").wysihtml5()
PS:基于https://github.com/jhollingworth/bootstrap-wysihtml5/issues/52的解决方案