# RJS/link\_to\_remote

**URL:** <https://www.ruby-forum.com/t/rjs-link-to-remote/78429>\
**Category:** Ruby\
**Created:** [December 5, 2006, 8:33pm UTC](https://www.ruby-forum.com/t/rjs-link-to-remote/78429 "2006-12-05T20:33:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsimone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jsimone](https://www.ruby-forum.com/u/jsimone)\
**Post date:** [December 5, 2006, 8:33pm UTC](https://www.ruby-forum.com/t/rjs-link-to-remote/78429/1 "2006-12-05T20:33:49Z")

</div>

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”, "

etc...

with the etc… being replaced by the content that should be showing in  
the browser. Any suggestions would be appreciated.

---

<div class="post-metadata">

**Author:** ![jsimone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jsimone](https://www.ruby-forum.com/u/jsimone)\
**Post date:** [December 5, 2006, 8:35pm UTC](https://www.ruby-forum.com/t/rjs-link-to-remote/78429/2 "2006-12-05T20:35:59Z")

</div>

Sorry, I thought I submitted this in the “Rails” forum. I’ll post it  
there now.
