I have an ajax method that creates a new form. I want one of the
input boxes to be focused when the form gets displayed. So in my
inline RJS I have
page <<
"document.getElementById(''post_title'').focus();"
The input box is being created with
<%= text_field ''post'', ''title'' %>, so
the ID should end up being
''post_title'' - FireFox''s DOM inspector confirms it.
However the text field isn''t getting focused, so I must be doing
something wrong. Any advice?
Pat
Give this a try:
page.send :record,
"document.getElementById(''post_title'').focus()"
--
View this message in context:
http://www.nabble.com/Focus-on-ajax-newly-created-form-element-t1381109.html#a3709254
Sent from the RubyOnRails Users forum at Nabble.com.
Surely you can just use... page[''post_title''].focus On 4/2/06, scottymac <scottmcmillin@gmail.com> wrote:> > > Give this a try: > page.send :record, "document.getElementById(''post_title'').focus()" > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060402/d0e3474f/attachment.html