javascript - Rails 4 - jQuery to hide initially, then toggle with click -


im having trouble resolving conflicts between jquery , javascript.

one of javascript conflicts comes trying use dependent-fields gem. see outline of problem here: rails - conflicts between jquery , javascript

instead of trying solve problem, i'm trying figure out how make jquery code directly manipulates forms hide , show data in way gem serves (or intended do).

i have made file in app/assets/javascripts called: projects.js.coffee. has:

$(document).ready(function() {     $("#check_project_milestones").hide() }); 

im not expecting toggle part, hoping might work hide content in check_project_milestones tag. doesnt.

in projects form, have:

<%= f.input :has_milestones, as: :boolean, boolean_style: :inline, :label => 'does research project have identifiable milestones or decision points?', id: 'check_project_milestones' %>                          <%= content_tag :div, data: {'checkbox-id': 'check_project_milestones', 'checkbox-value': 'true' } %>                              <div class="intpol2">                               milestones                             </div>                             <%= f.simple_fields_for :milestones |f| %>                                <%= render 'milestones/milestone_fields', f: f %>                             <% end %>                         <% end %>                         <div class="row">                          <div class="col-md-6">                             <%= link_to_add_association 'add milestone', f, :milestones, partial: 'milestones/milestone_fields' %>                          </div>                       </div>   

my objective first question hidden. when first question checkbox ticked, remainder visible. if box subsequently unticked, reverts being hidden.

can see i've done wrong?


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -