On Jan 2, 2008, at 3:11 AM, Vapor .. wrote:
>
> In RJS, how can I reset particular field (password) of form, but not
> login?
If this is an AJAX call, you can use render :update such as
render :update do |page|
page << "$(''password_field_id'').value =
'''';"
page << "$(''password_field_id'').focus();"
end
If going that route, I''d probably write a javascript function to do
it and then just call the function
render :update do |page|
page << "reset_password();"
end
or even
page.call ''reset_password''
>
> And also how can I bring cursor to input field when page is loaded? I
> currently have to click in the login field before typing.
>
Depending on how you''ve structured your layouts and views, you can
assign something to the onload event handler of the body tag
<body onload="$(''field_id'').focus();">
Probably, though, you are using layouts and don''t have very easy
access to the body tag, so you can something like this at the bottom
of your view
<script type="text/javascript">
$(''field_id'').focus();
</script>
or even render a partial to do it if you might need it on multiple
pages. You could pass the DOM id in as a local to make it DRY.
I''m sure there are other ways to accomplish your goals, but these can
at least be jumping off points.
Peace,
Phillip
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---