problems with link_to_remote

dweinand wrote:

i have a problem using an action with link_to_remote.

here the call the way it works: ----------------------------------------------------------------------- <%= link_to "Print", :controller => "preisliste", :action => "print_list", :id => @list.id%> -----------------------------------------------------------------------

in controller: ----------------------------------------------------------------------- send_data Report.generate_report(xml, report, jasper_type, xml_start_path),         :filename => "#{filename}.#{extension}", :type => mime_type, :disposition => 'inline' -----------------------------------------------------------------------

send_data sends a generated PDF file to the browser. works fine.

but if i'm using link_to_remote the PDF file isn't displayed. i'm using different log entries to get sure everything worked fine. the log entries are the same using both methods.

here the remote call: ----------------------------------------------------------------------- <%= link_to_remote "Print2",   :loading => 'show_wait()',         :complete => 'hide_wait()',   :failure => "alert('HTTP Error ' + request.status + '!')",   :url => {:action => :print_list, :id => @list.id} %> -----------------------------------------------------------------------

what am i missing?

You can have the link_to_remote RJS do a redirect to the PDF file, or have it open a new window with its URL set to the send_data action.

But if you stick with a plain link you can still show a wait indicator in the link's onclick event, and hide it in its onblur event. To show an error you can have the action do something other than send data.