Solved

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

Posted on 2013-01-07
4
399 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

861 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now