views:

73

answers:

2

Hi, I intend to use the following code to replace the partial web page called "activitypage", but instead I got a filedownload window with the message "Do you want to save the file or find a program to open". Why? Thanks,

render :update do |page|
    page.replace_html ('activitypage', :partial => 'index')
  end
  return
A: 

How are you calling this? It could be a problem in the client side code. If it's invoked by an Ajax.request then you may need to set the evalJS option to true.

Alternatively try :content_type => 'text/javascript' in your page.replace_html call.

edit --->

Just been looking at the docs for remote_form_for and I think you may get some success by adopting a slightly different approach.

If your controller does a straight

render :partial => 'index'

and you add the following option to the remote form tag

:update => "activitypage"

But that doesn't really answer you original question. I would recomend having a good look at the response header using WireShark or the Tamper Data plugin for FireFox (not sure if Tamper Data shows responses to ajax requests or not). I'ts likely that something is wrong with the content_type or disposition headers. It could have something to do with your server configuration.

(I hate these type of problems where it should "just work".)

Noel Walters
A: 

Hi, Noel, Thanks for your reply. Here is the whole picture, I hope.

In client page there is a submit button as defined like that,

 <div class="form_row">
<% form_remote_tag :url => {:controller => '/group', :action => 'add'},
:html => {:action => {:controller => '/group', :action => 'add'}} do %>
<%= submit_tag "Add!", :class => "submit" %>

<% end %>

In the function Add of controller group, I have the code,

def add //add the member into the group table //then go back to the /group/index page //which will replace the content in webPage "activitypage" render :update do |page| page.replace_html ('activitypage', :partial => 'index') end return end

In the backend, the controller:action (here /group/add) worked as expected, but in the client browser, a filedownload window was popped up for saving or opening a file?

I am confused!??????

erwin
the clause ", :html => {:action => {:controller => '/group', :action => 'add'}" seems to be unnecessary. But I don't know if that is cause of your problem. Try getting rid of it perhaps?What do you see in the downloaded file if you allow it to proceed?
Noel Walters