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
on 2006-04-02 02:35
on 2006-04-02 03:48
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-... Sent from the RubyOnRails Users forum at Nabble.com.
on 2006-04-02 06:21
Surely you can just use... page['post_title'].focus