June 14, 2006
Older: Using App Guts in Your Plugins
Newer: Railsday SVN
RJS Class Proxies
You might already know that you can call the following from an RJS template …
page.form.reset('some-form')
to generate the following Javascript code …
Form.reset("some-form");
This works because Form is a class in prototype which is bundled with Rails. However, did you know that the RJS class proxy will also work with your own included Javascript classes?
Let’s say you have the following Javascript class …
var Message = {
say:function(text) {
alert('You just said: ' + text);
}
}
I just learned tonight that you can call this in RJS like so …
page.message.say('I love RJS!')
which would produce …
Message.say('I love RJS!');
Man is that cool.
0 Comments
Thoughts? Do Tell...