RJS/link_to_remote error

Joe Smith wrote:

I'm trying to build an WebFTP application in Rails for some practice.

Here is a link located in a partial named _display_file that is called by a partial named _list_files. A similar link is created for every directory in the FTP

<%= link_to_remote filename ,                    :url => {:action => 'chdir' , :ftp_dir => filename},                    :update => 'ftp_div' %>

It should, to my understanding, make a call to the 'chdir' action and use the results to update the ftp_div.

The controller action 'chdir' is shown below:

def chdir   @ftp = session['ftp']

  @ftp.chdir( params[ :ftp_dir ] )   session['ftp'] = @ftp   @list = @ftp.list("-a") end

btw, I can store the ftp object inside a session because I've enabled memory_cache instead of other session types. So that's not the issue, it works without the AJAX.

Finally the file chdir.rjs is shown below:

page.replace_html("ftp_div" , :partial => "list_files" , :object => @list)

So basically, the user should be able to click on the directory and the directory listing should be updated without a page refresh. Instead I get this error when click on one of the links:

RJS error:

TypeError $(element) has no properties

Afterwords I get a "notice" box containing what appears to be the code I would like to appear in the ftp_div division... It looks something like this:

Element.update("ftp_div", "<!-- Start FTP List table --> <table border=\"1\"> etc...    In my experience, javascript doesn't like double quotes (") very much. Maybe try page.replace_html(:ftp_div ... or page.replace_html('ftp_div'... instead?

Regards, Henning