Forum: Ruby on Rails Executing a static javascript function after every event

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.
F409daac708858784c119dcc55428182?d=identicon&s=25 prism (Guest)
on 2007-07-24 14:30
(Received via mailing list)
Hi,

is there any way to (automatically?) call a javascript function
whenever something has happened in the view? Or at least when the view
has changed.

I.e. I have a function that vertically resizes and positions elements
on a page after checking the content, and I'd like it to update those
every time the content has changed.

With <body onLoad="setY()">, it only works for the first view, "/" or
"/frontpage/", but not the rest.

The html, head (and script), body tag, etc is located in a partial,
_a.rhtml, that is in views/layouts and is used across the different
views, like frontpage.rhtml, news.rhtml and so on.

Thanks,
Bjørn
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2007-07-24 16:10
(Received via mailing list)
prism wrote:

> is there any way to (automatically?) call a javascript function
> whenever something has happened in the view? Or at least when the view
> has changed.

My Short Cut with O'Reilly describes how to abuse^W activate the
prototype.js handlers like this:

  Ajax.Responders.register({ onComplete: function(request) {...} } )

Then detect your event type inside that handling method.

--
 Phlip
  http://www.oreilly.com/catalog/9780596510657/
 "Test Driven Ajax (on Rails)"
 assert_xpath, assert_javascript, & assert_ajax
This topic is locked and can not be replied to.