> I realize there is a group of people who'd like to just write everything in 
> Ruby (i.e. get to
> use javascript without having to know javascript), but I think that's a red 
> herring.

That's not the main issue, but without MinusMOR, your RJS files would
always look like
page << "some_jquery_code;"
page << "some_jquery_code;"
I don't mind writing JavaScript myself either, but in order for jQuery
for Rails to be easily integrated into existing applications, the
helpers are a must. I have my fair share of applications that combine
both helpers and sporadically some custom JS code, but I don't want to
refactor all my RJS and view code just for being able to integrate
jQuery instead of proto/script. If it could be plug-and-play (and not
plug-and-pray) I wouldn't doubt and just deploy new versions of my
AJAXed apps just for jQuery.

> Here are the main issues I've run into:
> + unobtrusively including js specific to a view

... and a Rails way of keeping the behavior in a separate file
(separate behavior from representation). What I would do now, is
either use a partial to render the JS in the header and put it in my
layout or just add JS files to the public/javascripts directory, but I
don't find it very Rails-like, it doesn't feel like the best solution.

> So, in whatever.rhtml, do something like:
>
>      <% javascript :file => 'path/to/plugin.js' %>
>      <% javascript :text => %{ $('p').css('color','blue'); } %>
>      <p>Whatever...</p>
>      <% javascript :text => %{ $('p').css('font-size', '2em'); }% %>
>
> And get:
>
>      <html>
>        <head>
>          <script type="text/javascript" src="whatever.js"></script>
>        </head>
>        <body>
>          <p>Whatever...</p>
>        </body>
>      </html>

Looks like Luke Redpath's UJS4Rails way of doing things :-) It's not a
bad solution, but UJS4Rails has introduced unreliable behavior in some
of the apps I have been working on.

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to