How to resolve jQuery Conflict with Sitecore in Sitecore Page Editor Mode

Load your js file right before calling the script

   <script language="javascript" type="text/javascript" src="xxx.js"></script>         

To make your life easier wrap your code in an anonymous function and pass the jQuery variable in. This is probably more obvious if you’re writing some code others will use like a jQuery plugin, but could help save you down the line.

Adding the anonymous function and passing the jQuery variable in will prevent problems later with the $ variable.


<script type="text/javascript">
    (function ($) {
        $(document).ready(function () {
            // Do some awesome stuff...
        });
    })(jQuery);

</script>  
      
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s