如何在x-editable中打印html响应(tinymce)

How to print html response (tinymce) in x-editable

本文关键字:响应 tinymce html 打印 x-editable      更新时间:2023-09-26

使用x-editable和tinymce来编辑字段,但是返回值会打印出来,显示html代码(使用

等),当重新加载页面时,这是可以的。

保存字段时显示内容的示例;

<p>this is a test response</p>
<p>&nbsp;</p>

this is a test response
 

可编辑初始化代码:

 $('.editable').editable('option','validate', function (v) {
     if (this.dataset.type == 'textarea') {
        return {newValue: tinyMCE.activeEditor.getContent()};
     }
 });

这是可编辑字段:

    <%= editable @article, :introduction, url: article_update_path(@article), type: 'textarea', onblur: 'ignore' %>

我希望它显示的是"html输出",而不是html代码。

问题已解决:

 $('.editable').editable('option','display', function (value, sourceData) {
     this.innerHTML = value;
 });