Rails: Make (link_to "example", "#", Remote: True) Bypass (respond_to ... Format.js)
I have the following problem: On my page I have 2 remote links. The first is:
<%= link_to 'Description', '#', remote: true, id: 'desc-link' %>
which is aSolution 1:
The first link does not need remote: true
. Setting that causes jquery_ujs to try to submit the link automatically via ajax when you click it. Removing remote: true
should prevent the toggle link from triggering the objects
action.
Separately, your click
handler should either return false
or call e.preventDefault()
to prevent the browser from trying to follow the link (basically you're telling the browser "ignore this click, I handled it"):
$(document).on"ready page:load", ->
$("section.object").on"click", "#desc-link", (e) ->
$("#object-desc").fadeToggle()
e.preventDefault() // <-- prevents following the link
Post a Comment for "Rails: Make (link_to "example", "#", Remote: True) Bypass (respond_to ... Format.js)"