Using RJS to call custom JavaScript class/method

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 (Particletree » 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

Hi Jeremy,

Use this:

page << ‘your.custom.javascript.here();’

Cheers!

-David F.

page << ‘alert(“Howdy!”);’

Use this:

page << ‘your.custom.javascript.here();’

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

-Jeremy

Jeremy M. wrote:

Use this:

page << ‘your.custom.javascript.here();’

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

-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