I’ve been doing some work on the Ajax Scaffold
(http://www.ajaxscaffold.com/), to make it work with file uploads
(more specifically, the file_upload plugin).
The first logical step was to get rid of form_remote_tag, since it’s
impossible to send files via XMLHTTPRequests (to my best knowledge).
So I referred to the iframe hack, similar to the upload progress bar
The way I found to perform an action upon successful form submission
rendered in the hidden iframe. It gets executed, it works perfectly
But here’s the problem: I wanted to simply “import” the RJS files that
come with the Ajax Scaffold. The way I figured to do that was to do
write my view (the one getting rendered in the hidden iframe) like
#### END CODE ####
# all the RJS goes here end %>
Sounds like it will work. But here’s the catch: all the elements that
the RJS code above is referring to are supposed to be in the same page
preceed their ID’s with “window.parent.document.getElementById”, so
the code inside the iframe is actually targetting the page “hosting”
it, and that’s where the elements we want to manipulate are.
So my question is: is there a way to do it via RJS? I thought that
something like “page.parent” existed, but it doesn’t. It also comes to
my mind a hack, where the parameters you supply to the RJS functions
don’t get quoted, meaning if I did something like this:
It would output “window.parent…” with no surrounding quotes. If that
worked, Prototype would find the element just fine.
The only other choice I have here is actually fetching all the JS
output, and writing it all in the view, changing the target for the
Prototype functions. But that sounds cranky to me.