I have a scenario where I need to show the preview of form in a new window.
I am stuck on how to invoke the rails action preview from javascript function and how to launch a new window for that action.
Here's the code:
click preview link code:
<%= link_to_function "#{image_tag('preview.png', :alt=>'Preview', :title=>'See a preview')}
<span class='text'>Preview</span>",
"javascript:show_form()" %>
javascript function:
function show_form() {
//grab the dom
var html = $('#newform').clone();
//whats next here?????
}
rails action:
def preview
@html = params[:html]
end
My question is:
- How do I call the rails action preview?
- how do I launch a new window with the preview for that action?
thanks for your help
Edit:
I am able to post data using $.post('/url') from jquery. However, the view is not being rendered. I can see that the view is being called(debug hits the breakpoint) but the browser does not render it. Is there anything I need to do in the .post() method to route to the new url?