I want to do some DOM manipulation with JavaScript. Specifically I
want to implement zoom in/out in a picture by changing it’s
width/height attributes. Is it possible to do this using RJS or should
I write javascript by hand?
All the examples of RJS I’ve seen write the javascript in the result
of an AJAX remote call. Where are the docs for RJS? All I’ve seen are
blog posts.
I don’t want to do any roundtrips to the server, but just have some
links that trigger functions. I’ve seen link_to_function so all I’m
missing is a way to write the javascript functions themselves in RJS.
Does it have functions so set/get stuff from the DOM? Should it be
used like this at all?
Thanks,
Pedro.
On 8/18/06, Pedro Côrte-Real [email protected] wrote:
I want to do some DOM manipulation with JavaScript. Specifically I
want to implement zoom in/out in a picture by changing it’s
width/height attributes. Is it possible to do this using RJS or should
I write javascript by hand?
SNIP
I don’t want to do any roundtrips to the server, but just have some
links that trigger functions. I’ve seen link_to_function so all I’m
missing is a way to write the javascript functions themselves in RJS.
Does it have functions so set/get stuff from the DOM? Should it be
used like this at all?
If you want to avoid roundtripping, then RJS isn’t what you want (by
design
it always involves a trip to the server). The JS you need doesn’t sound
too
complex, so unless you need to calculate the zoom server-side you should
be
fine with writing it yourself.
On 8/18/06, Jim K. [email protected] wrote:
If you want to avoid roundtripping, then RJS isn’t what you want (by design
it always involves a trip to the server). The JS you need doesn’t sound too
complex, so unless you need to calculate the zoom server-side you should be
fine with writing it yourself.
I was guessing that this was how it worked. I was hoping to be able to
write everything in ruby. Anyway, it’s a simple ammount of javascript
and even IE should not be much of a problem. I’ll keep my fingers
crossed.
Pedro.
Pedro Côrte-Real wrote:
write everything in ruby. Anyway, it’s a simple ammount of javascript
and even IE should not be much of a problem. I’ll keep my fingers
crossed.
Jim K. overstates the case, you can use the RJS JavaScriptGenerator
methods to write your javascript if you’re trying to keep as much as
possible in Ruby. Look at the PrototypeHelper#update_page_tag method.
I think they’re still a bit weak for general js authoring use though,
you’ll need to use page << "some literal javascript"
for things that
aren’t supported in the generator methods.
–
Devin Ben-Hur 503/860-4114 mailto:[email protected]
You may not have noticed, but we live in one of the safest,
most peaceful, times in human history. In the US, the three
leading causes of death are: killing yourself, killing yourself,
and killing yourself http://tinyurl.com/msxhq.
–
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.3/423 - Release Date:
8/18/2006