1

我有一个“编辑模式”,其文本区域由 API 响应填充。它工作得很好。当我激活 WYSIHTML5 时,文本区域返回空。我尝试过其他富文本编辑器,但它们都不允许填充文本区域。有什么办法可以让它工作吗?

在这里,我调用 API:

$('.btnEditNews').live('click', function () {

        var data = new FormData();
        var xhr = new XMLHttpRequest();
        var jsonResponse;

        xhr.addEventListener("readystatechange", function () {
          if (this.readyState === 4) {
            jsonResponse = JSON.parse(this.response)['singleNews'];
            $('#titleNews').val(jsonResponse.title);
            $('#textNewsBody').html(jsonResponse.newsText);
            $('#imgNews').attr('src', jsonResponse.file);
          }
        });

        xhr.open("GET", url);
        xhr.send(data);

      });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

调用 WYSIHTML5:

$('#textNewsBody').wysihtml5({
      "font-styles": true, //Font styling, e.g. h1, h2, etc. Default true
      "emphasis": true, //Italics, bold, etc. Default true
      "lists": true, //(Un)ordered lists, e.g. Bullets, Numbers. Default true
      "html": false, //Button which allows you to edit the generated HTML. Default false
      "link": false, //Button to insert a link. Default true
      "image": false, //Button to insert an image. Default true,
      "color": false //Button to change color of font  
    });
<script src="lib/js/wysihtml5-0.3.0.js"></script>

先感谢您!

4

0 回答 0