user3382438
user3382438

Reputation: 131

bootstrap-wysihtml5-rails with simple_form

I just started programming with Ruby on Rails and I really like it. I have a small page with a form (using gem simple_form) and I also integrated twitter bootstrap.

This part is working fine. But now I want to use the bootstrap-wysihtml5-rails editor (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.

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?

Thank you very much

Upvotes: 0

Views: 1813

Answers (1)

Edward
Edward

Reputation: 3499

In your form, for the content field do

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

Then in your application.js add

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

Upvotes: 3

Related Questions