我有一个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链接这里
发布于 2018-05-07 10:33:51
您应该能够使用下面的方法实现相同的目标
$("#<%=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的解决方案
发布于 2019-09-11 08:32:34
对我来说,这起作用了:
$('.wysihtml5-sandbox').contents().find('body').html(descr)我的页面上只有一个Wysihtml5,多个,您需要使用更精确的选择器。
发布于 2020-05-25 09:25:01
下面的代码适用于我
<textarea class="wysihtml5 form-control" rows="15" id="txtContent" runat="server"></textarea>
<script type="text/javascript">
function GetContent() {
var evnt = {RECORD_ID:'101'};
$.ajax({
type: "post",
url: '/API/GetContent',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(evnt),
success: function (result) {
if (result) {
var editorObj = $("#<%=txtContent.ClientID%>").data('wysihtml5');
var editor = editorObj.editor;
editor.setValue(result.CONTENT);
}
}
});
}
</script>https://stackoverflow.com/questions/50159344
复制相似问题