Jeremy Maziarz
2006-Apr-06 20:47 UTC
[Rails] 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 (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 -- Posted via http://www.ruby-forum.com/.
David Felstead
2006-Apr-06 23:28 UTC
[Rails] Using RJS to call custom JavaScript class/method
Hi Jeremy, Use this: page << ''your.custom.javascript.here();'' Cheers! -David Felstead On 4/7/06, Jeremy Maziarz <jeremy.maziarz@gmail.com> wrote:> 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 > > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
page << ''alert("Howdy!");'' -- Posted via http://www.ruby-forum.com/.
Jeremy Maziarz
2006-Apr-07 02:38 UTC
[Rails] Re: Using RJS to call custom JavaScript class/method
> Use this: > > page << ''your.custom.javascript.here();''Wow. High five. Works like a charm. Thanks a million! :) -Jeremy -- Posted via http://www.ruby-forum.com/.
Jeremy Maziarz wrote:>> Use this: >> >> page << ''your.custom.javascript.here();'' > > Wow. High five. Works like a charm. Thanks a million! :) > > -JeremyHave 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 -- Posted via http://www.ruby-forum.com/.