Catching "keypress" event with observe_field

I’m desperately trying to update a div when a key is pressed in a text
field.

Eg. :

<%= observe_field :field, :url => {:action => :myAction}, :update => :area, :with => "text_param", :on => 'keypress' %>

This does not seem to work, and I can’t understand why. Does someone
have any clue on what I am doing wrong ?

Thanks in advance

I don’t use AJAX, but I’ll see if I can help.

Just some thoughts:

  1. Right click on the loaded page and view source to make sure
    javascript is in the headers. Maybe observe_field isn’t being loaded.
  2. Instead of using keypress, does it work with frequency? I know that
    is not what you want, but it might give you some ideas.
  3. Try text_field_tag as well for the input.

Thanks for you reply !

  1. Right click on the loaded page and view source to make sure
    javascript is in the headers. Maybe observe_field isn’t being loaded.

Yep, it’s loaded.

  1. Instead of using keypress, does it work with frequency? I know that
    is not what you want, but it might give you some ideas.

Already done that, and yes, it works very well.

  1. Try text_field_tag as well for the input.

Just tried, but it doesn’t work either. I really don’t know what to try
next…

Thanks anyway

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