Forum: Ruby on Rails Using RJS to call custom JavaScript class/method

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.
Jeremy M. (Guest)
on 2006-04-07 00:47
The announcement for RoR 1.1 shows some nice examples of RJS calls. In
particular I am interested in this one:

# Call the custom JavaScript class/method AddressBook.cancel()
page.address_book.cancel

In trying to develop a "lightbox" style modal form, I have been
successful in saving the form data via AJAX but I can't seem to close
the "lightbox". I am using the Particletree.com "Lightbox Gone Wild!"
implementation (http://particletree.com/features/lightbox-gone-wild/)

How exactly do I call custom JavaScript?

Using 'page.lightbox.deactivate' throws the error: 'RJS error:
ReferenceError: Lightbox is not defined'.

Thanks,
-Jer
David F. (Guest)
on 2006-04-07 03:29
(Received via mailing list)
Hi Jeremy,

Use this:

page << 'your.custom.javascript.here();'

Cheers!

-David F.
Peter (Guest)
on 2006-04-07 03:30
page << 'alert("Howdy!");'
Jeremy M. (Guest)
on 2006-04-07 06:38
> Use this:
>
> page << 'your.custom.javascript.here();'

Wow. High five. Works like a charm. Thanks a million! :)

-Jeremy
Piers (Guest)
on 2006-05-08 14:06
Jeremy M. wrote:
>> Use this:
>>
>> page << 'your.custom.javascript.here();'
>
> Wow. High five. Works like a charm. Thanks a million! :)
>
> -Jeremy

Have a similar problem, but think I may be being thick.

I've a lightbox-style login working (in that the form_remote logs me in
OK), but the window doesn't close and the "You are logged in as ..."
blurb doesn't update.  Any clues where I should put the

page << 'Lightbox.hideall();'

Or do I need to do something different?

Thanks

Piers
This topic is locked and can not be replied to.