【问题标题】:Need help getting Wysihat to work需要帮助让 Wysihat 工作
【发布时间】:2011-02-25 13:41:32
【问题描述】:

我在一个 Rails 项目中使用 Wysihat,但它无法绑定到我的名为 post_description(模型名称 Post 字段名称描述)的文本区域,对此我感到很困惑。

我的 head 标签中有以下内容:

    <%= javascript_include_tag 'prototype_1.7'%>
    <%= javascript_include_tag 'wysihat' %>

    <script type="text/javascript" charset="utf-8">
    document.on("dom:loaded", function() {
      var editor = WysiHat.Editor.attach('post_description');
      var toolbar = new WysiHat.Toolbar(editor);
      toolbar.addButtonSet(WysiHat.Toolbar.ButtonSets.Basic);

      // Hide our error message if the editor loads fine
      $('error').hide();
    });
  </script>

我能够看到 Wysihat 的工作原理(显示粗体、斜体和下划线工具,并且单击时按预期工作)。帖子/新 HTML 的源代码中的以下内容:

<div id="post_description_editor" class="editor" contenteditable="true"></div>
<textarea cols="40" id="post_description" name="post[description]" rows="20" style="display: none; "></textarea>

但是,当我在描述字段中输入内容并单击提交时,帖子验证失败,说明描述字段为空。任何人都知道我该如何让它工作?

提前致谢!

【问题讨论】:

    标签: javascript ruby-on-rails forms wysiwyg wysihat


    【解决方案1】:

    这肯定会对你有所帮助:

    http://github.com/80beans/wysihat-engine

    【讨论】:

    • 谢谢你。我之前见过 wysihat-engine 但想以低开销实现它。然而,在一段时间没有弄清楚之后,我决定只使用它。让事情变得超级简单。
    猜你喜欢
    • 2017-09-22
    • 2015-02-11
    • 1970-01-01
    • 2020-11-15
    • 1970-01-01
    • 1970-01-01
    • 2014-10-10
    • 1970-01-01
    • 2020-09-08
    相关资源
    最近更新 更多