Forum: Ruby on Rails observe_form without ajax?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Payton S. (Guest)
on 2006-03-22 03:40
(Received via mailing list)
This betrays my lack of javascript knowledge, but is it possible to
watch a whole form for changes and activate some javascript when those
changes occur without any remote request?

That is, I want to do exactly what observe_form does, but without the
ajax call actually happening.  I realize I could use the form_tag
:onchange parameter, but that seems to be incapable of doing things like
updating a DOM element style.

Currently I just put my javascript in :complete and have the ajax render
:nothing => true, but that's a hack and uses unnecessary bandwidth.

Payton S. (Guest)
on 2006-03-22 04:11
(Received via mailing list)
Although in danger of answering my own question, I just discovered how
to work prototype's Form.Observer.  It appears to do the trick, although
it means I have to encapsulate my javascript in a separate function in
order to use the callback feature.

Sorry to trouble you all.

Jonathan Y. (Guest)
on 2006-03-22 15:36
(Received via mailing list)
If you are running EdgeRails or the new Rails 1.1.0 RC1 release
candidate then you can do this in your view:

<%= observe_form 'form_id', :frequency => 2, :function => "alert
('Form changed')" %>

The :function option can be any javascript that you want to execute.

This topic is locked and can not be replied to.