jeudi 20 juillet 2017

How to set a checkbox value to checked after clicking on a link in Rails?

I have an unordered list which I can expand by clicking on each list element.

list.html.erb

<input id="toggle" type="checkbox" unchecked>
<label for="toggle">
    <li>Implementing Bootstrap</li>
</label>
<div id="expand">
     ...
     ...
</div>

I am able to go from main.html.erb to list.html.erb right to the the list element by clicking on a link.

main.html.erb

<li><%= link_to "Implementing Bootstrap", list_path(:anchor => "toggle") %></li>

Additionally I want that the checkbox value is checked of the given linked element after I click on the link so the list element on list.html.erb will be exapneded right away.

How can I achieve this?




Aucun commentaire:

Enregistrer un commentaire