For anyone else who finds this thread...

There's a plugin called "embedded javascripts":
http://agilewebdevelopment.com/plugins/embedded_javascripts

In a nutshell, it defines ActionView::Base#include_javascript , which
takes the name of a Javascript file as an argument, processes any ERB
in the JS file, and returns the JS code sandwiched between <script
type="text/javascript" ..> and </script>.

That sounds like a good tool to use in a solution for the originally-
stated problem. However, it doesn't feel right to me. The Javascript
file will never be cached by browsers, and it adds another call to
read from the file system, which will slow things down a bit. However,
for a small app, I think it's a great tool.

Dan Webb released two plugins - MinusR and MinusMOR - with the latter
being an update of the former:
http://www.danwebb.net/2006/11/17/rjs-minus-r
http://www.danwebb.net/2006/11/24/minusmor-released

I like MinusMOR, as it doesn't hijack the .rjs file extension.
However, I don't think it's a tool that could [easily] be used to
solve the original problem. But it's still a pretty cool plugin!

In the end, I've decided to hard-code HTML elements' DOM IDs in views,
partials, RJS templates, Javascript files, and wherever else. On top
of that, every element that is touched by Javascript will have its DOM
ID prefixed with "x_". This will make it very clear which elements'
DOM IDs shouldn't be changed on a whim.

What I've just explained is Robby Russell's approach. He explained it
quite well in a blog post:
http://www.robbyonrails.com/articles/2007/08/01/designers-developers-and-the-x_-factor

Cheers,
Nick
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to