Stenly Yiu
Stenly Yiu

Reputation: 181

Sitecore Preview can't load javascript

When I setup Sitecore and use the Preview function, all the javascript cannot be loaded (like the pull down effect, overlay, etc.).

Just want to confirm if the preview function of sitecore does not support javascript? Otherwise, how to make it fixed? Anything I missed during setup? Thanks.

Upvotes: 1

Views: 597

Answers (2)

jammykam
jammykam

Reputation: 16990

The better way to do fix this is to write your JavaScript in isolated scopes using current best practices and you will never have issues with your code regardless of which library is used.

Avoiding jQuery’s noConflict() Mode with Prototype and Sitecore

var Example = {};

(function($){
   Example.test = function(){
      $("#worker").remove();
   }

   $(function(){ // domloaded shortcut
      Example.test();
   });
})(jQuery);

Upvotes: 1

Derek Dysart
Derek Dysart

Reputation: 1396

A couple things to check:

  • Sitecore versions prior to 6.5 use the Prototype javascript library, which binds to the '$' variable. If you are using jQuery on your pages, use the explicit 'jQuery' reference or 'jQuery.noConflict()'. Versions after 6.5 use jQuery and also assign their version to a non conflicting variable ('S$' iirc
  • Make sure there aren't any errors in your own javascript. This one may sound obvious, but given javascript's nature, one small error will take down the rest of the code.

Upvotes: 1

Related Questions