When you try to create a SharePoint visual webpart that makes use of jQuery, it is generally known that any conflict will cause the javascript rendering to fail, e.g. any document.ready() function.
It is common when you have a lot of customized components that were activated as a feature.
You can easily check whether you have loaded conflicting versions of jQuery from viewing the source on the web page. But how do you control whether or not to load the jQuery if it already exists?
Solution:
Check whether the jQuery object can be created, before loading the .js file using javascript.
if (typeof jQuery == 'undefined') {
var jq = document.createElement('script'); jq.type = 'text/javascript';
// Path to jquery.js file
jq.src = '/_layouts/Test/jquery.min.js';
document.getElementsByTagName('head')[0].appendChild(jq);
}
Showing posts with label jquery. Show all posts
Showing posts with label jquery. Show all posts
Wednesday, October 8, 2014
Wednesday, November 27, 2013
SharePoint 2010: Display scrolling list items using jQuery and SPServices
This is a pretty common requirement for intranet administrators, so today I thought I'd share how to display the contents of a SharePoint list using jQuery. The good part about this is you need to have some knowledge on the CAML query and that's it.
First download these 3 components and store it somewhere accessible on SharePoint. Thanks to the wonderful folks who did the hard work and came up with those great components!
jQuery - http://jquery.com/
jQuery.SPServices - http://spservices.codeplex.com (read documentation thoroughly for compatibility)
jQuery.Marquee from givainc - http://www.givainc.com/labs/marquee_jquery_plugin.cfm
(in the case of jQuery Marquee, make sure you also include the css file for default styling)
Create a simple text file and include references to those components. I am using a plain text file so that I could include it later in a Content Editor Webpart.
First download these 3 components and store it somewhere accessible on SharePoint. Thanks to the wonderful folks who did the hard work and came up with those great components!
jQuery - http://jquery.com/
jQuery.SPServices - http://spservices.codeplex.com (read documentation thoroughly for compatibility)
jQuery.Marquee from givainc - http://www.givainc.com/labs/marquee_jquery_plugin.cfm
(in the case of jQuery Marquee, make sure you also include the css file for default styling)
Create a simple text file and include references to those components. I am using a plain text file so that I could include it later in a Content Editor Webpart.
<link rel="stylesheet" href="/sites/SiteCollectionDocuments/jquery.marquee.min.css" />
<script src="/sites/SiteCollectionDocuments/jquery-1.8.3.js"></script>
<script src="/sites/SiteCollectionDocuments/jquery.marquee.min.js"></script>
<script src="/sites/SiteCollectionDocuments/jquery.SPServices-2013.01.min.js"></script>
Labels:
jquery,
sharepoint
Thursday, November 21, 2013
Creating tabbed menus with jQuery and CSS
While searching for free code downloads that allow me to create tabbed browsing effects with minimal fuss and zero dependency, I stumbled across this gem: jQueryUI
This is really cool as it makes use of the latest version of jQuery to display nice effects and best of all, it is extremely easy to plug this piece of code onto any environment (SharePoint included) :P
There are a lot more useful utilities out there. I just did not have the luxury of trying them all.
Labels:
jquery
Subscribe to:
Posts (Atom)