Skip to content
Permalink
Browse files

Place the cursor at the end when the input has content

  • Loading branch information
dcadenas committed May 30, 2009
1 parent 595b553 commit a00165a8211b23f905db1c32c5198d0edc0b2c25
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/autofocusable.rb
@@ -22,7 +22,10 @@ def set_focus method_name, options
return '' if is_disabled?(options) || is_readonly?(options)

if @is_autofocusable && !@template.instance_variable_defined?('@focus_was_set')
@template.instance_variable_set('@focus_was_set', @template.javascript_tag("document.getElementById('#{tag_id(method_name)}').focus()"))
@template.instance_variable_set('@focus_was_set', @template.javascript_tag(<<-JSCODE))
document.getElementById('#{tag_id(method_name)}').focus();
document.getElementById('#{tag_id(method_name)}').value = document.getElementById('#{tag_id(method_name)}').value;
JSCODE
else
''
end

0 comments on commit a00165a

Please sign in to comment.
You can’t perform that action at this time.