需要帮助让 Wysihat 正常工作
我在 Rails 项目中使用 Wysihat,但它无法绑定到名为 post_description (模型名称发布字段名称描述)的文本区域,这让我感到困惑。
我的 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>
但是,当我在描述字段中输入内容并单击“提交”时,帖子验证失败,说明描述字段为空。有人知道我如何让它发挥作用吗?
提前致谢!
I'm using Wysihat in a rails project and am stumped by its inability to bind to my textarea named post_description (model name Post field name description).
I have the following in my head tag:
<%= 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>
I'm able to see Wysihat works (the bold, italic, and underline tools are shown and when click works as intended). The following in the source of the posts/new 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>
However, when I type something in the description field and click submit the post validation fails saying the description field is empty. Anyone have any clue on how I can get this to work?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这肯定会对您有所帮助:
http://github.com/80beans/wysihat-engine
This will definitely help you:
http://github.com/80beans/wysihat-engine