jQuery & Rails installation

I'm missing something basic ...

How does one install jQuery in RoR?

The old fashioned way. Download it from jQuery.com and stick the .js files in public/javascripts. jQuery is not "supported" by the javascript helpers in Rails. But if you're doing unobtrusive javascript, you won't care.

Steve Ross wrote:

I'm missing something basic ...

How does one install jQuery in RoR?

The old fashioned way. Download it from jQuery.com and stick the .js
files in public/javascripts. jQuery is not "supported" by the javascript
helpers in Rails.

But you can use the jrails plugin for that.

But if you're doing unobtrusive javascript, you won't
care.

And you should be doing unobtrusive JS, in which case Rails' helpers are
indeed not much use.

FWIW, I just started using jQuery. I'm a bit underwhelmed with its
architecture. I may go back to Prototype, although I would like to get
to know both libraries better before I make that decision.

Best,

There are several blog posts on how to use jQuery unobtrusively with
Rails. Yeah, don't use the js helpers and RJS if you can avoid it!
I'm currently in the process of creating a jQuery application template
to install/configure jQuery widgets, jQuery UI and unobtrusive jQuery
in a Rails app.
Check my github rails3-templates at kristianmandrup.

Have fun!

BTW: If you want to learn jQuery, get the "jQuery in Action" book!

There are several blog posts on how to use jQuery unobtrusively with

Rails. Yeah, don’t use the js helpers and RJS if you can avoid it!

I’m currently in the process of creating a jQuery application template

to install/configure jQuery widgets, jQuery UI and unobtrusive jQuery

in a Rails app.

Check my github rails3-templates at kristianmandrup.

Have fun!

BTW: If you want to learn jQuery, get the “jQuery in Action” book!

“jQuery in Action” is a very good book but make sure that you get

the 2nd edition which covers jQuery 1.4.

Cheers,

-Conrad

Ralph Shnelvar wrote:

I'm missing something basic ...

How does one install jQuery in RoR?

Use the following line in your layout

Note: you may encounter conflicts if you are using Prototype and Jquery
together. In that case, use
*********************************************************
jQuery.noConflict(); and then instead of "$" use "jQuery"
*********************************************************

Somethng I am using ... validates_captcha ... uses Prototype.

Hmm ... I wonder if this explains the odd behavior I am seeing when I
tried to use the jQuery plugin, IconDock:
   http://icon.cat/wiki/IconDock_En#iconDock_jQuery_Plugin

So ... I read
   http://docs.jquery.com/Using_jQuery_with_Other_Libraries
and my question is: What are the odds that there will be a conflict?

How can I find out definitely if validates_captcha conflicts with
jQuery?

Ralph Shnelvar wrote:

Somethng I am using ... validates_captcha ... uses Prototype.

You could monkey-patch the render_regenerate_challenge_link of
the captcha provider to emit jquery specific javascript.

Or fork the project and make it js lib independent.

Martin

Ralph Shnelvar wrote:

Note: you may encounter conflicts if you are using Prototype and Jquery
together. In that case, use
*********************************************************
jQuery.noConflict(); and then instead of "$" use "jQuery"
*********************************************************

Somethng I am using ... validates_captcha ... uses Prototype.

Hmm ... I wonder if this explains the odd behavior I am seeing when I
tried to use the jQuery plugin, IconDock:
   http://icon.cat/wiki/IconDock_En#iconDock_jQuery_Plugin

So ... I read
   http://docs.jquery.com/Using_jQuery_with_Other_Libraries
and my question is: What are the odds that there will be a conflict?

How can I find out definitely if validates_captcha conflicts with
jQuery?

Remove jQuery and see what happens.

But really, if you use noConflict, there should be noIssue. :slight_smile:

Best,

Well if you're observing validates_captcha acting odd when you're
using jQuery, or vice-versa, you've found out....

Another easy way to avoid conflict between the various JS libraries is
to do something like this:

jQuery.noConflict();
(function($) {
.... //jquery code goes here, allowing you to use $ willy-nilly...
})(jQuery);

you'll need to make sure that the jQuery.noConflict() call comes
*before* any code using Prototype or whatever runs (as
validates_captcha uses the inline rjs helpers this shouldn't be a
concern, but I've yet to actually *use* validates_captcha so you'll
see)

Completely offtopic though, I find jQuery overwhelmingly useful and
intuitive. Granted, while its more just a "DOM manipulation, ajax and
effects" library where Prototype is a general purpose Javascript
framework, Javascript's *soo* flexible and powerful that a library
adding class-based inheritance and enumerators everywhere often gets
in the way of the "Javascript-way" of doing things.

Martin Andert wrote:

Ralph Shnelvar wrote:

Somethng I am using ... validates_captcha ... uses Prototype.

You could monkey-patch the render_regenerate_challenge_link of
the captcha provider to emit jquery specific javascript.

Or fork the project and make it js lib independent.

That is sooo far over my head.