Still fighting with the file upload thingy. I have the form in an iframe, now I''m trying to make a div in the main page update on submit. However, I can''t get it working at all, not even if I try to update a div in the iframe itself. This is my rhtml file that I''m loading within the iframe: <span class="style3">Upload New File</span> <p>Select a file to upload below.</p> <%= start_form_tag( {:action => ''create'' }, {:multipart => true, :onSubmit => "new Ajax.Updater(''testPleaseIgnore'', ''/resources/updatelist'', {asynchronous: true}); return false;" })%> <%= render_partial ''form'' %> <br /> <br /> <%= submit_tag "Upload File" %> <%= end_form_tag %> <div name="testPleaseIgnore" id="testPleaseIgnore"> Test Please Ignore </div> The mystifying part is that /resources/updatelist isn''t getting hit at all (I know the onSubmit is being called, because I put a javascript alert in there and it appeared without any problems). Any ideas? martin
On 10/28/05, Martin DeMello <martindemello-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > The mystifying part is that /resources/updatelist isn''t getting hit at > all (I know the onSubmit is being called, because I put a javascript > alert in there and it appeared without any problems). Any ideas?Okay, fixed that - I''d forgotten to include prototype.js in the inner page. Still stuck on updating a div in the parent page. martin
On Friday 28 October 2005 9:42 pm, Martin DeMello wrote:> On 10/28/05, Martin DeMello <martindemello-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > The mystifying part is that /resources/updatelist isn''t getting hit at > > all (I know the onSubmit is being called, because I put a javascript > > alert in there and it appeared without any problems). Any ideas? > > Okay, fixed that - I''d forgotten to include prototype.js in the inner > page. Still stuck on updating a div in the parent page. > > martinTry this page for a walkthrough screencast and complete code for the upload progress: http://sean.treadway.info/demo/upload ..and this one for a checklist of requirements: http://sean.treadway.info/articles/2005/07/18/upload-progress-checklist I managed to get it working for an order system used by a printing company to accept fairly large datafiles. My local prototype worked perfectly running on Apache 2/Debian Sarge, but when I deployed the site onto an Apache 1.3/Fedora Core VPS the upload worked, but the status bar doesn''t update. Haven''t worked that one out yet either. We have the minimum instances of fcgi set to 5 or 10 or something, and we''ve confirmed that we get at least 2 when initiating the upload, but for some reason the AJAX isn''t updating until the upload is complete. mark Easy Schedule Management http://easy-online-schedule
On 10/28/05, Mark Beattie <beattie.mark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Friday 28 October 2005 9:42 pm, Martin DeMello wrote: > > On 10/28/05, Martin DeMello <martindemello-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > The mystifying part is that /resources/updatelist isn''t getting hit at > > > all (I know the onSubmit is being called, because I put a javascript > > > alert in there and it appeared without any problems). Any ideas? > > > > Okay, fixed that - I''d forgotten to include prototype.js in the inner > > page. Still stuck on updating a div in the parent page. > > > > martin > > Try this page for a walkthrough screencast and complete code for the upload > progress: > > http://sean.treadway.info/demo/upload > > ..and this one for a checklist of requirements: > > http://sean.treadway.info/articles/2005/07/18/upload-progress-checklistThanks Mark, but I''m not trying to implement a full-fledged upload progress (I''m a bit worried about the fact that the requirements seem so fiddly, and I''d rather not give up the webrick option just yet), just a file list refresh once i''ve uploaded a file. I have my iframe rhtml saying <%= start_form_tag( {:action => ''create'' }, {:multipart => true, :onSubmit => "parent.refreshFileList()" })%> and my parent rhtml with function refreshFileList(){ alert(''hello world''); try { new Ajax.Updater(''fileListContainer'', ''/resources/updatelist'', {asynchronous: true}); } catch(e) { alert(e); } return false; } (plus a modification to prototype.js so that Try rethrows rather than swallowing the error), and it''s displaying the ''hello world'' alert properly, but then it throws up a "ReferenceError: ActiveXObject is not defined". I even tried wrapping it in a setTimeout as suggested by http://dema.ruby.com.br/articles/2005/05/06/be-careful-when-mixing-ajax-and-popup-windows-on-firefox but it still throws up the same error. martin
On 10/28/05, Martin DeMello <martindemello-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > (plus a modification to prototype.js so that Try rethrows rather than > swallowing the error), and it''s displaying the ''hello world'' alert > properly, but then it throws up a "ReferenceError: ActiveXObject is > not defined". I even tried wrapping it in a setTimeout as suggested byYeah, this one was my dumb mistake - another part of prototype relied on Try failing gracefully. Now it works wonderfully (yay!) For reference, this is the full sequence of things I had to do: 1. Make an iframe to hold the file upload form 2. Include prototype.js in both the upload page and the main page 3. In the iframe, have <%= start_form_tag( {:action => ''create'' }, {:multipart => true, :onSubmit => "setTimeout(''parent.refreshFileList()'', 1000)" })%> 4. In the main page, have function refreshFileList() { new Ajax.Updater(''fileListContainer'', ''/resources/updatelist'', {asynchronous: true}); return false; } Took me way too long (including over a day wondering why the AJAX form upload was silently swallowing file_fields (can Rails issue a warning for that?)), but I definitely learnt a lot about javascript in the process. Back to work (tight deadline that all this didn''t help) but I''ll try to post a minimal example to the wiki over the weekend. martin