Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am using Chrome (I know not fully supported) and I wrote a small little script to display the weather using jQuery and Yahoo weather.

The problem is once I placed it on the page, some parts of the ribbon (edit, page, browse, publish) no longer work in Chrome. Now while I know Chrome is not supported, it worked before.

This is my 1st little test in using jQuery within SharePoint, I launch the developer tools in Chrome (F12) to view the console and there are no errors.

Is there any other way I can try to debug what is happening?

share|improve this question
add comment

3 Answers 3

up vote 1 down vote accepted

This is most likely because the <body> attribute onload is not reached, or even overwritten by jQuerys document ready.

You can fix this by calling _spBodyOnLoadWrapper(), for example like this:

$(function() { 
  (window.navigator.userAgent + '').match(/Chrome/) && 
    !_spBodyOnLoadCalled && 
    window._spBodyOnLoadWrapper && 
    _spBodyOnLoadWrapper(); 
});
share|improve this answer
    
Do I put this in the same script in my weather widget? –  mdumka Nov 27 '12 at 15:50
    
Anywhere you like really, for example with script link. But to test this solution you can open up your console (F12) and run _spBodyOnLoadWrapper(), if this works you should immediately see improvements. –  eirikb Nov 27 '12 at 19:08
    
My god man ... you are a lifesaver! Thanks soooo Much! –  mdumka Nov 29 '12 at 18:21
add comment

I've never had any huge issues with the combination of Chrome, jQuery, and SharePoint that I can remember. Where are you calling your jQuery script? Header? Footer? And what are you calling your scripts on? I typically call on

$(document).ready(function(){
  // script here
})

and have never had problems in the past. Can you paste any kind of code sample? I can't confirm @eirikb's solution, but it sounds like it might help.

share|improve this answer
add comment

I would fix your issue by simulating JQuery's way of doing things and use an iifee to wrap your code up giving yourself localised variables.

The JQuery iife (Immediately invoked function expression) looks like this:

(function(window,document,undefined) {
    ... code here
})(this,document);

this refers to the window object in this case.

JQuery should never overwrite the document because of this, it actually has it's own copy to play with, so if it is then some thing's are broken with your JQuery.

So make yourself an instanced version of the page, and you should be fine for calling your functions, it's also good practice while working with any code to scope your variables, and iifes are used to scope variables in Javascript.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.