Topic: conflict between jquery and RJS?

I'm using rjs and everything works fine.  I'm also using thickbox which requires jquery.  If i have:

<%= javascript_include_tag 'jquery' %>

in my <head> then my rjs fails (no error..) but if I remove it, then everything works.  This is super bizarre and I'm wondering if anyone has seen it or knows a workaround?

Re: conflict between jquery and RJS?

I've never used jquery but some time ago I found an article saying

Given that the Prototype syntax for element proxies

Re: conflict between jquery and RJS?

jQuery and Prototype are interfering with each other. RJS is generating javascript code to be used with Prototype. Prototype and jQuery both use $() as their selector methods. To resolve this, you need to change (or get rid of) the jQuery $ shortcut. This can be done by..

<script src="js/jquery"></script>

<script>
jQuery.noConflict();

jQuery(document).ready(function(){
   jQuery("div").hide();
});

</script>


or you can assign it to a different shortcut...

<script src="js/jquery"></script>

<script>
$j = jQuery.noConflict();

$j(document).ready(function(){
   $j("div").hide();
});
</script>

Last edited by cleanwhistle (2007-07-23 19:43:35)

Sam

Re: conflict between jquery and RJS?

Yeah, I had tried that.. eventually I just used a prototype compatible lightbox..

Posts [ 4 ]

Pages 1