Solved

Sharepoint Web Part sometimes causing left hand navigation menu to be hidden

Posted on 2013-01-07
4
403 Views
Last Modified: 2013-01-11
I've created a web part in SharePoint 2007. I have had complaints from several users that sometimes the left hand navigation menu ("View All Site Conent", "Documents", "Lists", etc.) does not show. This behavior is not consistent. The user can load the page the first time and the panel is visible, then refresh the page and the panel disappears or vica versa. Any ideas on what might cause this behavior?
0
Comment
Question by:ZaDrizzle
  • 2
4 Comments
 
LVL 9

Expert Comment

by:kukdai
ID: 38753353
where does it happen is it happening in all browsers or just some particular browsers.
do you have any java script in your master pages.
try it in your own machine.
clear your cache and try again and see if you can reproduce the problem
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38753749
Hi,
what is this web part doing?
Perhaps the web part does not create valid html (eg missing closing tags).
If possible post the html output.
Thanks.
Rainer
0
 

Author Comment

by:ZaDrizzle
ID: 38756026
Thanks for the feedback and sorry for the slow response. It turns out that the masterpage and my webpart are both importing the same jquery library.

<script type="text/javascript" src="/_catalogs/masterpage/js/jquery/jquery-1.4.2.min.js"></script>

Open in new window


This is causing my jquery selector to fail when the page loads. I don't understand why this wouldn't throw an error everytime instead of only sometimes.
 $(function() {
 $("input[id$='usernameTxtBx']").autocomplete({
            source: function (request, response){
                $.ajax({
                type: 'POST',
                contentType: 'application/json; charset=utf-8', 
                url: '~/_layouts/UsernameAutoComplete.asmx/GetUsernames',
                data: "{ 'partialUsername': '" + request.term + "', 'maxResults': '10' }",
                dataFilter: function(data){return data;},
                success: function(data) {
                    response($.map(data.d, function (item){
                        return{
                            label: item,
                            value: item
                        }
                    }))
                }
            });
        },
        minLength: 1
        });
    });

Open in new window

I know I can just take the line to import the jquery library out of my webpart, but if the web part were to get loaded on a page that did not import the library, then the webpart would also fail. What would be an appropriate way to handle this?
0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 38756193
Hi,
try this from http://buffernow.com/how-to-check-if-jquery-is-loaded/
<script type="text/javascript">
if (typeof jQuery != 'undefined') {}else{
var head = document.getElementsByTagName("head")[0];
script = document.createElement('script');
script.id = 'jQuery';
script.type = 'text/javascript';
script.src ='//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js';
head.appendChild(script);
}
</script>

Open in new window


HTH
Rainer

BTW, you might want to follow these two recommendations as well:
http://www.stephanrocks.com/2011/10/05/_spbodyonloadfunctionnames-in-sharepoint-vs-jquerys-document-ready/
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question