使用prototype.js在sharepoint 2010中解析和读取XML文件而不禁用编辑模式

发布于 2024-11-14 15:05:48 字数 1422 浏览 1 评论 0原文

我正在为我的公司在 sharepoint 上制作一个仪表板,涉及从网站集合中其他页面的列表和库中检索信息。我正在使用 Corasworks 工具(Sharepoint 站点列表提供程序)以 XML 文件形式检索子站点列表,为此我使用“prototype.js”构建了一些 javascript 代码,并使用我自己的个人方法来读取和解析该文件。我在 Internet Explorer 上外部测试了该文件,它运行良好,检索了我需要的信息。然后我尝试在 Sharepoint 2010 上实现它,效果很好,但是,当我返回尝试向我的页面添加另一个 Web 部件时,我无法做到这一点,然后发现该页面抛出了一个 javascript 错误,其中包含以下内容:

线路:3 字符:13993 错误:类型不匹配 代码:0 url:(我的网站网址)

我回去并逐行调试我的代码,看看它在哪里崩溃,并发现以下第一行是罪魁祸首:

     <script src="prototype.js" type="text/javascript"></script>

                                    <script src="flightDashboard.js" type="text/javascript"></script>
                                    <script>
                                    _spBodyOnLoadFunctionNames.push("ajaxCall");

                                    </script>

我当然做了一些研究,发现使用原型。 Node.js 会导致某些 microsoft javascript 函数崩溃,因为它扩展了它们使用的某些信息和方法。 我寻找解决这个问题的方法,因为我的主管希望我使用prototype.js,因为它易于在浏览器之间兼容。到目前为止,我已经找到了一些非常模糊的答案,这些答案是为有类似问题的人提供的,如下所示:

“如何使用 EditModePanel 控件包装脚本文件引用,以便仅在页面处于显示模式时才呈现它,并且不是编辑模式。 < PublishingWebControls:EditModePanel PageDisplayMode="Display" runat=server id="EditModePanel1">将你的js引用放在这里< / PublishingWebControls >

“ - Michael O' Donovan

但是,他没有指定在哪里实现此代码,因此我尝试在我的代码上实现此代码,当我在 Sharepoint Designer 中保存页面时,Web 部件变得无效并且没有太大帮助 这让我被困了好几天,

我真的找不到任何可以继续的东西,我真的很感激任何可以帮助我实现这一目标的信息或提示。

I'm working on making a dashboard for my company on sharepoint, involving retrieving information from lists and libraries of other pages in the website collection. I'm using a Corasworks tool (Sharepoint Site List Provider) to retrieve a list of subsites as an XML file, for which I have built some javascript code using 'prototype.js' and my own personal methods to read and parse through the file. I tested the file externally on internet explorer and it works perfectly, retrieving the information I needed. I then tried to implement it on Sharepoint 2010, and it worked nicely, however, when I went back to try to add another web part to my page, I couldn't and then found out the page threw a javascript error which contained the following:

Line:3
Char: 13993
Error: Type Mismatch
Code: 0
url: (my website url)

I went back and debugged my code line by line to see where it was crashing, and found out the following first line to be the culprit:

     <script src="prototype.js" type="text/javascript"></script>

                                    <script src="flightDashboard.js" type="text/javascript"></script>
                                    <script>
                                    _spBodyOnLoadFunctionNames.push("ajaxCall");

                                    </script>

I did some research of course, and found out that using prototype.js causes some of the microsoft javascript functions to crash because it extends certain information and methods that they use.
I searched for ways to work around this problem because my supervisor wants me to use prototype.js because of its ease of compatibility between browsers. So far I've come around some very vague answers that were given to people with a similar problem, like the following:

"What about wrapping the script file references with the EditModePanel control so that it only get's rendered when the page is display mode and not edit mode. i.e.
< PublishingWebControls:EditModePanel PageDisplayMode="Display" runat=server id="EditModePanel1">put your js references in here < / PublishingWebControls >

" - Michael O' Donovan

However, he didn't specify where to implement this code, so I tried implementing this on my code and when I saved the page in Sharepoint Designer, the web part became invalid and it wasn't of much help.

This has kept me stuck for several days and I really can't find anything to move on, I would really appreciate any information or tips that could help me achieve this. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花落人断肠 2024-11-21 15:05:48

您将无法解决此问题。 PrototypeJS 不能很好地与其他 javascript 库配合使用,因为它改变了 javascript 的工作方式。请参阅此处:

我该如何与prototype.js 并排使用FancyUpload(与mootools)?

PrototypeJS 没有“安全模式”操作,在这种模式下它不会进行可能导致其他库出现问题的更改。

您的两个选择是

1) 将 prototype.js 代码隔离在 iframe 内,这样它就不会与 sharepoint webparts 冲突。

2)切换到另一个javascript库。大多数 sharepoint 开发人员会推荐 jQuery。

You won't be able to work around this problem. PrototypeJS doesn't work very well with other javascript libraries since it makes changes to the way javascript works. See here:

How can I use FancyUpload (with mootools) side by side with prototype.js?

PrototypeJS doesn't have a "safe mode" of operation where it doesn't make changes that can cause problems with other libraries.

Your two options are

1) Isolate the prototype.js code inside of an iframe so it doesn't conflict with sharepoint webparts.

2) Switch to another javascript library. Most sharepoint developer would recommend jQuery.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文