【问题标题】:Bootstrap wysihtml5 editor - can't insert html using JSBootstrap wysihtml5 编辑器 - 无法使用 JS 插入 html
【发布时间】:2014-10-06 18:12:53
【问题描述】:

我想在 textarea 中插入一些 HTML (html_string):

var editorElement = $("#my_textarea").wysihtml5();
var wysihtml5Editor = editorElement.data("wysihtml5").editor;
wysihtml5Editor.composer.commands.exec("insertHTML", html_string);

但是,这似乎只有在我首先至少单击了一次 textarea 时才有效。有没有其他人看过这个? (JS 调试器不会产生错误)。

【问题讨论】:

    标签: javascript jquery twitter-bootstrap ruby-on-rails-4


    【解决方案1】:

    你试过了吗:

    $("#my_textarea").val(html_string);
    

    或者也可以在您的代码之后尝试:

    editorElement.data("wysihtml5").editor = wysihtml5Editor;
    

    你能做一个 JSFiddle 吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-01
      • 1970-01-01
      • 2015-01-19
      • 2021-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多