Good evening, I am having a bit of a problem and was wondering if anyone could help me out.. I have a form in my view, which contains a text_area. When the user focuses on the text area and presses a key - i would like to execute an action - only ONCE.. I can perform these events using :onkeypress => remote_function... However, this obviously calls my funtion every time a key is pressed - i would only like the function to be called once - is this a possibility?? any ideas of a work around?? Thanks for your time.. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Well, from what you''ve posted, it looks like you want to use
observe_field.
So it would go something like this:
<%= text_field ''name'', ''method'', ...
%>
...
<%= observe_field ''name[method]'', :url => {:controller
... }, :update => ...
%>
Check out the API docs for full usage information, but this will send an
AJAX request when the user leaves the field.
Jason
On 2/2/07, Matthew Williams
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> Good evening,
>
> I am having a bit of a problem and was wondering if anyone could help me
> out..
>
> I have a form in my view, which contains a text_area. When the user
> focuses on the text area and presses a key - i would like to execute an
> action - only ONCE..
>
> I can perform these events using :onkeypress => remote_function...
>
> However, this obviously calls my funtion every time a key is pressed - i
> would only like the function to be called once - is this a possibility??
>
> any ideas of a work around??
>
> Thanks for your time..
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
well, one thought would be to set a flag on the first keypress.
something like
<%= text_area ..., :onkeypress => "mykeypress()" -%>
<script type="text/javascript">
var key_flag = false;
function mykeypress() {
if(key_flag == false) {
key_flag = true;
new AjaxRequest(...);
}
}
</script>
On 2/2/07, Matthew Williams
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
> Good evening,
>
> I am having a bit of a problem and was wondering if anyone could help me
> out..
>
> I have a form in my view, which contains a text_area. When the user
> focuses on the text area and presses a key - i would like to execute an
> action - only ONCE..
>
> I can perform these events using :onkeypress => remote_function...
>
> However, this obviously calls my funtion every time a key is pressed - i
> would only like the function to be called once - is this a possibility??
>
> any ideas of a work around??
>
> Thanks for your time..
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---