-
Notifications
You must be signed in to change notification settings - Fork 1
proxies
Eric Draut edited this page Jul 7, 2016
·
6 revisions
<% if to_do.done? %>
<%= ajax_link '', undo_to_do_path(to_do), {id: dom_id(to_do, :undo_link)} %>
<input type="checkbox" <%= click_proxy(dom_target(to_do, :undo_link)) %> checked="checked">
<% else %>
<%= ajax_link '', complete_manage_to_do_path(to_do), {id: dom_id(to_do, :undo_link)} %>
<input type="checkbox" <%= click_proxy(dom_target(to_do, :undo_link)) %>>
<% end %>
<%= to_do.description %>
Assuming this partial is swappable via AJAX, then checking the box will click the AJAX link to either complete or undo a to_do item. This allows you to click a link by clicking any other element you choose.
n.b. this example uses Thin Man for AJAX behavior.
<%= form_for payment do |f| %>
<a <%= submit_proxy %>>Make Payment</a>
<% end %>
Clicking the Make Payment
link will submit the form. This allows you to submit a form with any element, not just a button.