How to use rails.js and prototype.js librarys

The problem

I wanted to use some interface element in Rails that requires prototype.js so I had to have both librairies. The problem is that there's a conflict between them. Prototype.js doesn't seem to give a damn about it but jQuery is nicer with you. It offers a noConflict method.

With Rails, prototype.js is the default librairie so to override this, you could do

  1. <%= javascript_include_tag "prototype", "jquery" %>
  2. <script>$j = jQuery.noConflict();</script>

This way, you will have to use $j instead of $ to call jQuery.$ would still call prototype.

Another thing you could do is to use jQuery on Rails and don't give a damn about scriptaculous. I personally prefer to use librairies that are fully tested instead of using a "by-pass" that could break my code. It's your choice…



--
                                                                                   G SubbaRao
                                                                                   Cell:08970668850
                                                                                   E-Mail:subbarao.kly@gmail.com

Comments

Popular posts from this blog

Rails Memcache issues

Enabling password authentication for new ec2 box | ssh, ssh config, EC2 setup, new user in EC2, PasswordAuthentication

What's the difference between "include" and "require" in Ruby?