【问题标题】:jquery in sharepoint webpart issue: object doesn't support this property or method in javascriptsharepoint webpart 问题中的 jquery:对象不支持 javascript 中的此属性或方法
【发布时间】:2012-09-10 18:24:33
【问题描述】:

我在 sharepoint webpart 中运行此 jquery 代码,并在运行时在网页上收到此错误object doesn't support this property or method in javascript

我已经正确添加了对 js 文件的引用。

    <script src="../../Style Library/Styles/jquery-1.7.1.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Style Library/Styles/jquery.imagemapster.min.js"></script>
<script>
     $(document).ready(function () {
            var image = $("#ImageMap1");
            image.mapster({
                fillOpacity: 0.4,
                fillColor: "d42e16",
                stroke: true,
                strokeColor: "3320FF",
                strokeOpacity: 0.8,
                strokeWidth: 4,
                singleSelect: true,
                mapKey: 'shape',
                listKey: 'shape'
            });
</script>

我认为这是因为控件的 id 被渲染,我试图传递客户端 id 但我仍然遇到同样的问题并且它不起作用。如果在普通的 asp.net 应用程序上使用,上面的 jquery 可以正常工作

谁能帮帮我。

【问题讨论】:

    标签: jquery sharepoint-2010 web-parts


    【解决方案1】:

    尝试像这样包装你的脚本:

    ExecuteOrDelayUntilScriptLoaded(
        function() {
            $(document).ready(function () {
                var image = $("#ImageMap1");
                image.mapster({
                    fillOpacity: 0.4,
                    fillColor: "d42e16",
                    stroke: true,
                    strokeColor: "3320FF",
                    strokeOpacity: 0.8,
                    strokeWidth: 4,
                    singleSelect: true,
                    mapKey: 'shape',
                    listKey: 'shape'
                });
        }
    
    , "sp.js");
    

    这将等待加载和执行 SharePoint javascript mess 内容

    【讨论】:

    • 我复制了同样的内容,但我收到了The value of the property 'ExecuteOrDelayUntilScriptLoaded' is null or undefined, not a Function object的错误
    【解决方案2】:

    在这里查看函数:http://msdn.microsoft.com/en-us/library/ff411788.aspx

    如果您使用上述方法,我认为您不需要 ready() 函数。 问候, KS

    【讨论】:

      猜你喜欢
      • 2013-03-23
      • 1970-01-01
      • 2010-11-05
      • 2011-04-27
      • 2011-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多