Forum: Ruby on Rails observe_form without ajax?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5224d56434a3d237408c217605df8a56?d=identicon&s=25 Payton Swick (Guest)
on 2006-03-22 02: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
5224d56434a3d237408c217605df8a56?d=identicon&s=25 Payton Swick (Guest)
on 2006-03-22 03: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.

-Payton
609e59bf8c5bfef51d142de60f1e5a2a?d=identicon&s=25 Jonathan Younger (Guest)
on 2006-03-22 14: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.

-Jonathan
This topic is locked and can not be replied to.