Reputation: 360
I want to use
link_to 'Cancel', edit_project_path(@project, url_options)
to cancel the edit and go back to the edit page.
I use jQuery UI Tabs for a tabbed edit page. Each tab has it's own form and submit/cancel buttons.
When I click a Cancel link I want to go back to the active tab. So I set
url_options = {:anchor => active_tab_id}
The problem is: the page doesn't reload because of the anchor.
Adding data-no-turbolink
does not help:
link_to 'Cancel', edit_project_path(@project, url_options), :data => {:no_turbolink => true}
Upvotes: 6
Views: 6355
Reputation: 153
try using
<%=link_to("Cancel", edit_project_path(@project, url_options), method: :get)%>
this helped me better
Upvotes: 13
Reputation: 945
The only way to do it is with javascript.
Add custom data attribute to the link:
link_to 'Cancel', edit_project_path(@project, url_options), :data => { :reload => true }
Then put this javascript somewhere, for example in app/javascripts/reload_hash.js
$(function(){
$('a[data-reload="true"').on('click', function(e) {
window.location = $(e.target).attr('href');
window.location.reload(true);
});
});
Upvotes: 6