简体   繁体   中英

SharePoint 2010 Motools JavaScript incompatibility

I created a JavaScript Slideshow base on Slideshow2 using Mootools. It works great stand-alone. I decided to incorporate it into my SharePoint 2010 Master Page and at first glance it was working great, but for some strange reason other native SharePoint javascript code on the page stopped working. Some JavaScript code such as the “Create” button from “View All site content” does nothing and some drop downs from the global navigation menu. I first noticed when I tried to approve the saved master.page and when I clicked on Approve nothing happened.

I began to delete all my JavaScript code and from process of elimination noticed that just by leaving the line: <script type="text/javascript" src="/_catalogs/javascript/mootools-1.3.2-core.js"></script> causes the error. Every other line doesn't seem to affect the other JavaScript code. I even substituted it to the most recent version and got the same result: <script type="text/javascript" src="/_catalogs/javascript/mootools-core-1.4.5-full-compat.js"></script>

It's possible that MooTools and the SharePoint script libraries are battling over the '$' alias. According to MooTools, the more recent versions will attempt to detect the dollar alias being used and not steal it. This is dependent on the Mootools library being loaded after other scripts. See "The Dollar Safe Mode" for more info.

I would suggest moving MooTools to the bottom of your Master Page (just before the closing body tag), and seeing if that helps. I've not used MooTools, but I assume that there is something similar to jQuery's $(document).ready() method that allows you to invoke your MooTools code only after the core library has been loaded.

尝试将此代码插入到母版页中以包含MooTools库:<SharePoint:ScriptLink ID =“ MooToolsJS” runat =“ server” Name =“ / _ catalogs / javascript / mootools-core-1.4.5-full-compat.js “ LoadAfterUI =” true“ OnDemand =” false“ />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM