Reputation: 577
so i have a Exam controller. Now the the file for it has a jqgrid (index.html.erb )on it. One clicks on the grid row and i have set upped the javascript for handling the event. it looks like
<script type= "text/javascript">
function handleSelection(id) {
<%=
remote_function :url => render_exam_exams_path,:with => "'id='+id"
%>
}
</script>
now the the method i was just testing as follows
def render_exam
@exams = Exam.find(params[:id])
#either
#redirect_to home_index_path
#or open this in new browser tab
#render :action => "render_exam"
end
and I have a view called render_exam as well. Now i have checked the server logs and all, everything works fine even the render_exam is generated as i could see that in chrome developer plugin. Now the problem is i want either
<script type= "text/javascript">
function handleSelection(id) {
<%= redirect_to :action => render_exam_exams_path, :with => "'id='+id" %>
}
</script>
otherwise the problem would have been solved. Any help is appreciated thanks
Upvotes: 1
Views: 5157
Reputation: 29135
First, you can't redirect and render in the same action since there's only one response per action. Second opening a new tab is a client side feature (controlled by your browser), you need to use something like ""target=_blank in your link which will open a new browser which in turn will request a page (render_exam_exams_path in your case) from the server.
Upvotes: 1