0

我正在使用两个库:qTip2 和 Jquery SVG。Jquery SVG 包含几个 js 文件,我有 jquery.svgdom.min.js 的问题。我与这两个库发生冲突的问题。当我禁用jquery.svgdom.min.js工作qTip正常时。如果它启用,那么我会收到以下错误:

Uncaught exception: TypeError: 'this.each' is not a function  
Error thrown at line 7, column 3420 in <anonymous function: $.fn.attr>(b, c, d) in http://localhost:46159/Scripts/jquery.svgdom.min.js:

如何解决?

这是我的代码:

 function setupTolltip() {
        var sessionId = $("#schemaImage").attr("session");
        var clientId = $("#schemaImage").attr("client");
        $("area").each(function () {
            var levelId = $(this).attr("level");
            $(this).qtip(
                {
                    content: {
                        text: 'Working...',
                        ajax: {
                            url: '/hall/GetInfoForLevel',
                            data: { levelId: levelId, sessionId: sessionId, clientId: clientId },
                            dataType: 'json',
                            success: function (json) {
                                var content = "<div>All: " + json.PlacesCount + "<br/>Free: " + json.FreePlacesCount + "</div>";
                                this.set('content.text', content);
                                return false;
                            }
                        }
                    },
                    position: {
                        target: 'mouse',
                        adjust: {
                            x: 10
                        }

                    },
                    style: {
                        classes: 'ui-tooltip-tipsy ui-tooltip-shadow'
                    }

                });
        });
    }

更新:
这是我的所有脚本:

<script src="@Url.Content("~/Scripts/jquery-1.7.2.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~//Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~//Scripts/jquery.galleriffic.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.16.custom.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.opacityrollover.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/custom-form-elements.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/datepicker.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.qtip.min.js")" type="text/javascript"></script>     
<script src="@Url.Content("~/Scripts/jquery.fancybox.js")" type="text/javascript"></script>

更新2:undefined用户:我试过这样:

var $j = jQuery.noConflict();

        var sessionId = $("#schemaImage").attr("session");
        var clientId = $("#schemaImage").attr("client");

        $j('area').each(function () {
....

但我得到错误:

Uncaught exception: TypeError: '$' is not a function
Error thrown at line 5, column 8 in setupTolltip():
    var sessionId = $("#schemaImage").attr("session");
called from line 49, column 12 in <anonymous function>():
    setupTolltip();
called via Function.prototype.apply() from line 2, column 23204 in <anonymous function: each>(a, c, d) in http://localhost:46159/Scripts/jquery-1.7.2.min.js:
    if(c.apply(a[g++],d)===!1)
called from line 2, column 16574 in <anonymous function: each>(a, b) in http://localhost:46159/Scripts/jquery-1.7.2.min.js:
    return e.each(this,a,b)
called from line 4, column 20656 in <anonymous function: complete>(a, b, c) in http://localhost:46159/Scripts/jquery-1.7.2.min.js:
    c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("<div>").append(c.replace(bM,"")).find(g):c)),d&&i.each(d,[c,b,a])
called via Function.prototype.apply() from line 2, column 29284 in <anonymous function: f.Callbacks>(b, f) in http://localhost:46159/Scripts/jquery-1.7.2.min.js:
    f=f||[],e=!a.memory||[b,f],i=!0,j=!0,m=k||0,k=0,l=c.length;
called from line 2, column 30902 in <anonymous function: fireWith>(b, c) in http://localhost:46159/Scripts/jquery-1.7.2.min.js:
    d&&(j?a.once||d.push([b,c]):(!a.once||!e)&&o(b,c));
called from line 4, column 24458 in w(a, c, l, m) in http://localhost:46159/Scripts/jquery-1.7.2.min.js:
    v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))
called from line 4, column 36227 in <anonymous function: d>(a, e) in http://localhost:46159/Scripts/jquery-1.7.2.min.js:
    m&&g(j,k,m,l)

解决方案:http: //forum.jquery.com/topic/svg-svgdom-error-this-each-is-not-a-function

4

0 回答 0