Html options :onkeypress

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…

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

well, one thought would be to set a flag on the first keypress.

something like

<%= text_area …, :onkeypress => “mykeypress()” -%>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs