Solved

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

Posted on 2013-01-07
4
411 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create a Dropdown list with sub group 10 43
orderby list (from Json) 1 44
Sharepoint question : What is a Simego cube 4 40
What is GIS method of Geometry data type? 6 36
Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 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