Giter Site home page Giter Site logo

Comments (4)

luciuschoi avatar luciuschoi commented on August 29, 2024

I have just cloned your repo and replaced the whole meds.coffee file as follows:

$ ->
  $('[data-provider="summernote"]').each ->
    $(this).summernote
      height: 100

It also worked properly on editing an presisted record and so I could see the multiple text fields held each corresponding attribute value correctly.

If you omit the height option line, summernote editor will not be shown.

Good luck!

from summernote-rails.

luciuschoi avatar luciuschoi commented on August 29, 2024

In meds.coffee file of your repo, you called summernote editor twice for individual fields.

First call is as follows:

$ ->
  $('[data-provider="summernote"]').each ->
    $(this).summernote()

Second calls are:

$ ->
  # to call summernote editor
  summer_note.summernote
  summer_note2.summernote
  summer_note3.summernote
  summer_note4.summernote
  summer_note5.summernote
  summer_note6.summernote
  summer_note7.summernote
    # to set options
    height:300
    codemirror:
      lineNumbers: true
      tabSize: 2
      theme: "solarized light"

Therefore, you must remove code lines for second calls.

If you want to add some options to a certain summernote editor, you must not add as: :summernote option for corresponding field input in form view file and call summernote editor for it additionally in meds.coffee.

So, you may modify the form view file(edit.html.erb) as follows:

<div class = "container">
<fieldset>
  </p><h2>Edit Medicine</h2></p>
  <%# if user_signed_in? && current_user.is_admin == true %>
  <%= simple_form_for @med, class: "form-horizontal" do |f| %>
    <div class="form-group">
    <%= f.input :brand_name, required: true %>
    </div>

    <div class="form-group">
    <%= f.input :generic_name, required: true %>
    </div>

    <div class="form-group">
    <%= f.input :description, as: :summernote, :id => 'description' %>
    </div>

    <div class="form-group">
    <%= f.input :reactions, as: :summernote, :id => 'reactions' %>
    </div>

    <div class="form-group">
    <%= f.input :interactions, as: :summernote, :id => 'interactions' %>
    </div>

    <div class="form-group">
    <%= f.input :implementation, as: :summernote, :id => 'implementation' %>
    </div>

    <div class="form-group">
    <%= f.input :availability, as: :summernote, :id => 'availability' %>
    </div>

    <div class="form-group">
    <%= f.input :caution, as: :summernote, :id => 'caution' %>
    </div>

    <div class="form-group">
    <%= f.input :warnings, :id => 'warnings' %>
    </div>

    <%= f.button :submit, class: "btn btn-primary" %> </div>
  <% end %>
  <%# end %>
</fieldset>
</div>

(In the above, you could find the absence of as: :summernote option for f.input :warnings, :id => 'warnings')

and also meds.coffee file as follows:

$ ->
  $('[data-provider="summernote"]').each ->
    $(this).summernote
      height:50

  summer_note7 = $('#med_warnings')
  summer_note7.summernote
    # to set options
    height:300
    codemirror:
      lineNumbers: true
      tabSize: 2
      theme: "solarized light"

(In the above, you could find the additional code line height:50.)

I wish it helps you. Good luck~

from summernote-rails.

rasool-sb avatar rasool-sb commented on August 29, 2024

@luciuschoi 👍

from summernote-rails.

jtansley avatar jtansley commented on August 29, 2024

Thank you so much for the thorough explanation! This worked perfectly!! I learned a great deal here.

from summernote-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.