Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Javascript Conflicts - Javascript not working *SOLVED*


Go to End


5 Posts   6584 Views

Avatar
CHD

Community Member, 219 Posts

4 January 2011 at 3:39pm

Hey,

i was pulling my hair out with this for a while.
I've been using custom JavaScript sideshows etc in my sites, but they stop working on pages with "image gallery" or "userdefinedforms" etc.

anyway, the solution was the JavaScript libraries conflicting with the use of "$"
putting this as the very end of my code solved it:

<script>
jQuery.noConflict();
jQuery(document).ready(function($){
$("#example").autocomplete();
});
</script>

I hope this helps others!

Avatar
DNS

Community Member, 1 Post

9 January 2011 at 8:54am

Thanks much... this just saved me some troubleshooting.

Avatar
edwardlewis

Community Member, 33 Posts

16 April 2011 at 10:50pm

where abouts do you put the code? in page.ss or in the js file that is causing the conflict?

Avatar
edwardlewis

Community Member, 33 Posts

16 April 2011 at 10:57pm

yes! just fixed it..

I used:

(function($) {
$(document).ready(function() {

// code;
})
})(jQuery);

at the top and bottom of the js file

Avatar
pinkp

Community Member, 182 Posts

26 April 2017 at 6:31am

I could kiss you! haha
Thats been annoying me for so long. I've found that script.js that comes with SS conflicts with my 3rd party JS scripts, removing Script.js makes them work. But then the responsive menu stops working! Wrapping my init.js scripts like you said has worked. thanks!