Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery not working right, possible conflicts with Prototype?

I'm sorry for the vague title.

I'm making a new theme for my company's website, and I've got both jQuery tabs and a slider on the page.

Both the tabs and slider aren't working though - I'm not too sure why. I inherited the design and simply changed the theme - I'm thinking it might have something to do with multiple jQuery scripts being loaded - the slider throws an error that the method .split() doesn't exist, and the tabs just don't work the way they should.

like image 938
Ben Harris Avatar asked Jun 22 '26 22:06

Ben Harris


1 Answers

You should do this:

<action method="addJs"><script>jquery/jquery.js</script></action>
<action method="addJs"><script>jquery/jquery.plugin.js</script></action>
<action method="addJs"><script>jquery/jquery.moreplugin.js</script></action>
<action method="addJs"><script>jquery/jquery.noConflict.js</script></action>

<action method="addJs"><script>prototype/prototype.js</script></action>

in page.xml layout.

jquery.noConflict.js file:

var jQuery = $.noConflict();

After that you can call jQuery() function everywhere you wish. The order is: jquery -> jquery plugin -> jquery no conflict -> prototype

like image 83
Lan Nguyen Avatar answered Jun 24 '26 13:06

Lan Nguyen