简体   繁体   English

SharePoint 2010 Motools JavaScript不兼容

[英]SharePoint 2010 Motools JavaScript incompatibility

I created a JavaScript Slideshow base on Slideshow2 using Mootools. 我使用Mootools在Slideshow2的基础上创建了JavaScript幻灯片。 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. 我决定将其合并到我的SharePoint 2010母版页中,乍一看它运行良好,但是由于某些奇怪的原因,该页面上的其他本机SharePoint Javascript代码停止运行。 Some JavaScript code such as the “Create” button from “View All site content” does nothing and some drop downs from the global navigation menu. 某些JavaScript代码(例如“查看所有网站内容”中的“创建”按钮)不起作用,而某些代码则从全局导航菜单中下拉。 I first noticed when I tried to approve the saved master.page and when I clicked on Approve nothing happened. 当我尝试批准保存的master.page并单击“批准”时,我首先注意到没有任何反应。

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. 我开始删除我所有的JavaScript代码,并从消除过程中注意到,只留下了这一行: <script type="text/javascript" src="/_catalogs/javascript/mootools-1.3.2-core.js"></script>导致错误。 Every other line doesn't seem to affect the other JavaScript code. 每隔一行似乎都不会影响其他JavaScript代码。 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> 我什至将其替换为最新版本,并得到了相同的结果: <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. MooTools和SharePoint脚本库可能正在争夺'$'别名。 According to MooTools, the more recent versions will attempt to detect the dollar alias being used and not steal it. 根据MooTools的说法,较新的版本将尝试检测正在使用的美元别名,而不是盗用它。 This is dependent on the Mootools library being loaded after other scripts. 这取决于在其他脚本之后加载Mootools库。 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. 我建议将MooTools移到母版页的底部(紧接在结束body标签之前),然后查看是否有帮助。 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,但是我假设有一个类似于jQuery的$(document).ready()方法的东西,该方法只允许在核心库加载后调用MooTools代码。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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