Jump to:

10929 Posts in 2613 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » UserForms: Javascript Conflict

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 850 Views
  • juneallison
    Avatar
    Community Member
    108 Posts

    UserForms: Javascript Conflict Link to this post

    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!

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: UserForms: Javascript Conflict Link to this post

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

  • juneallison
    Avatar
    Community Member
    108 Posts

    Re: UserForms: Javascript Conflict Link to this post

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

  • juneallison
    Avatar
    Community Member
    108 Posts

    Re: UserForms: Javascript Conflict Link to this post

    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!

    850 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.