In a Rails 3.2 app I have a coffeescript function that toggles a css class when a link is clicked.
#coffeescript
jQuery ->
$(".toggle-link").click ->
$(this).toggleClass "selected"
#view
<%= link_to "toggle", my_path, class: "toggle-link" %>
This works fine.
But if I move the link into an ajaxified partial, e.g. for pagination, the jquery toggle stops working.
Why is this?
And how can it be fixed?