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.

All other Modules /

Discuss all other Modules here.

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

UserForms: Javascript Conflict


Go to End


4 Posts   1320 Views

Avatar
juneallison

Community Member, 110 Posts

13 August 2011 at 8:18am

So I am using a variety of jquery scripts/plugins on my site. On most of the pages these work with no problem. But on my Contact page, all of these scripts break. I am assuming it has something to do with the Form's javascript.

On a related note, if I login to the SS admin interface and the Site Navigator appears on the front end, all of my scripts also break, on every page.

So is there anything that UserForm and SiteNavigator have in common that might cause all of my scripts to break?

Any ideas would be great.

Thanks!

Avatar
Willr

Forum Moderator, 5523 Posts

13 August 2011 at 3:05pm

Have you wrapped your javascript in closures? http://doc.silverstripe.org/sapphire/en/topics/javascript#custom-jquery-code. Normally that prevents most conflict errors.

Avatar
juneallison

Community Member, 110 Posts

13 August 2011 at 11:48pm

It looks like I had one script that wasn't wrapped. That did the trick. Thank you!!

Avatar
juneallison

Community Member, 110 Posts

14 August 2011 at 12:18am

Actually I am using one script, that when wrapped, still has a conflict with the SiteNavigator.

I am using this plugin: http://sorgalla.com/jcarousel/

And the script in my header looks something like this:
<script type="text/javascript">
(function($) {
$(document).ready(function(){
jQuery('#mycarousel01').jcarousel({
// Configuration goes here
});
jQuery('#mycarousel02').jcarousel({
// Configuration goes here
});
jQuery('#mycarousel03').jcarousel({
// Configuration goes here
});
jQuery('#mycarousel04').jcarousel({
// Configuration goes here
});
jQuery('#mycarousel05').jcarousel({
// Configuration goes here
});
jQuery('#mycarousel06').jcarousel({
// Configuration goes here
});
})
})(jQuery);
</script>

It works fine when the SiteNavigator isn't present but displays as a list (as opposed to a slider) when you're logged into the admin.

Any suggestions would be great. Thanks!