Hi everyone,
I have an upload form in my app, which obviously has a file_field. After
the user has selected a file I want to use an observe_field to check if
the selected file already exists on the server. I tried it like this,
but somehow it doesn''t work:
<%= file_field ''myfile'', ''myfile'' %>
<%= observe_field(''myfile_myfile'',
:update => ''error'',
:loading =>
"Element.show(''spinner'')",
:complete =>
"Element.hide(''spinner'')",
:url => { :controller => ''file'',
:action =>
''validate_filename'' } ) %>
When I edit the generated javascript a little bit and do it like this it
DOES work:
<%= file_field ''myfile'', ''myfile'',
:onchange => "checkFile();" %>
<script type="text/javascript">
function checkFile()
{
new Ajax.Updater(''error'',
''/file/validate_filename/<%=
controller.folder_id
%>'',
{ asynchronous:true,
evalScripts:true,
onComplete:function(request){Element.hide(''spinner'');}
onLoading:function(request){Element.show(''spinner'');},
parameters:document.getElementById(''myfile_myfile'').value
}
);
}
</script>
Is this a known issue with observe_field or am I doing something wrong?
I have another question about this: the spinner doesn''t dissapear in
Safari (it does work in Firefox; haven''t tried IE yet). Does anyone see
what I''m doing wrong there? As a work-around I let the controller send
back javascript to hide the spinner again, but it would much neater if
onComplete would just work.
Thanks!!
Mischa.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---