开发者

Multiple Checkboxes with HABTM - display details of each selected item using ajax

Am a newbie on RoR and would be grateful if you could help me out with this problem.

In my rails application, I have a form 'Submission' which contains a list of publications. User can link several publications to the Submission using the checkbox.

Each time user clicks in a checkbox, I would like to display the details of the publication selected. So if user has selected 3 publications, i would li开发者_C百科ke to display the details of the 3 publications selected and when user deselects a publication, i would like its details to disappear.

Here is the code of the publications list:

<% @publications.each do |publication| %>
  <p><%= check_box_tag "submission[publication_ids][]", publication.ID %></p>
  <p><%=h publication.name %></p>
  <p><%=h publication.desc %></p>
  <p><%=h publication.author %></p>
<% end %>

I would like to use ajax to display the puublication details each time a publication is selected and to remove the details when the publication is deselected.

Please can anyone give me an idea on how to do this.

Thanks a lot in advance for any suggestion provided

Thanks a lot for helping me out with this


You can have a partial for description of a publication.

And You can have an ajax call which trigger on click of checkboxes. Action will take the ID of publication and render the partial by which you can update the specified dom element.Ask if you have any further query.:)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜