简体   繁体   English

bootstrap-wysihtml5-带有simple_form的导轨

[英]bootstrap-wysihtml5-rails with simple_form

I just started programming with Ruby on Rails and I really like it. 我刚开始使用Ruby on Rails编程,我真的很喜欢它。 I have a small page with a form (using gem simple_form) and I also integrated twitter bootstrap. 我有一个带有表单的小页面(使用gem simple_form),并且我还集成了twitter引导程序。

This part is working fine. 这部分工作正常。 But now I want to use the bootstrap-wysihtml5-rails editor ( https://github.com/Nerian/bootstrap-wysihtml5-rails ). 但是现在我想使用bootstrap-wysihtml5-rails编辑器( https://github.com/Nerian/bootstrap-wysihtml5-rails )。

This is my form: 这是我的表格:

<%= simple_form_for (@article) do |f| %>
<%= f.input :title, label: 'Titel' %>
<%= f.input :body, label: 'Content' %>
<%= f.input :tag_list, label: 'Tags' %>
<%= f.button :submit %>
<% end %>

I setup the dependencies css and javascript. 我设置依赖项CSS和JavaScript。

I want to use the wysiwyg editor for the content field but I don't know how.. Can anyone give me an exampe for the content field? 我想对内容字段使用wysiwyg编辑器,但我不知道如何。有人可以给我示例内容字段吗?

Thank you very much 非常感谢你

In your form, for the content field do 在您的表单中,对于内容字段

 <%= f.input :content, label: 'Content' , input_html: { class: 'wysihtml5' } %>

Then in your application.js add 然后在您的application.js中添加

$(document).ready(function(){
  $('.wysihtml5').each(function(i, elem) {
    $(elem).wysihtml5();
  });
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM