I'm trying to simulate the response I get from clicking one of my Rails 3 AJAX links (remote => true) using javascript. But I wonder if I'm thinking about this whole thing the wrong way.
I have some AJAX links which swap page content in a dashboard. Like this:
<%= tabs_tag(:builder => RemoteTabsBuilder) do |tab| %>
<%= tab.preview 'Preview', unit_surveys_preview_path(@unit), :class => "mylink", :remote => true %>
<%= tab.sendpage 'Send', unit_surveys_send_path(@unit), :class => "mylink", :remote => true %>
<%= tab.home 'Results', unit_responses_results_path(@unit), :class => "mylink", :remote => true %>
<% end %>
This works as intended, with the ajax:success event replacing the main section of the page content. But within one of the pages I have some javascript that creates a modal overlay and what I want to do is reload the page after it completes.
I tried re-loading the whole page using:
format.js { render :redirect}
In the controller but I don't want to reload the whole dashboard, I just want to reload the 'Results' page content. So I'm thinking I want to simulate clicking on my existing link:
<%= tab.home 'Results', unit_responses_results_path(@unit), :class => "mylink", :remote => true %>
But
1) How can I do that using javascript (or jQuery)? (Based on this thread: doing a remote => true call with javascript I believe I can use $.get to simulate the click but that the Rails UJS responses will not be triggered)
2) I feel like I'm over complicating this. Is there a better way?