So, I have a remote form that, upon submission, displays a result and
itself again. I'd like, though, for it to clear the text field and
set the focus there when it redisplays. I've been able to get it to
focus the form properly, by setting :complete => "$
('phone_number').focus()". But, I've not been able to get it to focus
AND clear the fields. I've tried:
$('phone_number').focus();$('phone_number')..clear();
$('phone_number').focus().clear;
$('phone_number').activate();
All with no luck. Any suggestions?
I've included a more complete snippet below...
<% form_remote_tag :url => {:controller => 'phones',
:action => 'create'},
:update => 'phones',
:complete => "$('phone_number').focus();" do %>
<%= text_field 'phone', 'number', {:size => 12, :value =>
(@phone.number unless @phone.nil?).to_s} %>
<%= submit_tag "Add Phone" %>
<% end %>