这是迄今为止我在jQuery中遇到的最烦人和最奇怪的问题。这是荒谬的基础(那些墨菲定律中的一个)

我有一个div(divDialog):

    <div id="divDialog">
    </div>

我调用对话框函数:
    $('#divDialog').dialog();

它在 Firebug 中给了我这个错误:
    this.element[0].nodetitle is undefined

如果删除div,错误消失。如果我只淘汰选择器部分,
它显示了Firebug中的节点,一切看起来都很好。我目前正在通过以下方式扩展jquery:
$.fn.isAfter = function(sel){ //returns true if element is after, else return false, for animations
    return this.prevAll(sel).length > 0;
}
$.fn.isBefore= function(sel){ //returns true if element is before, else return false, for animations
    return this.nextAll(sel).length > 0;
}
$.fn.exists = function(){ //returns true if element exists, false if not
    return this.length>0;
}
$.fn.btnClick = function(fn){ //check if the element is disabled before executing onclick
    $(this).click(function(){
        if($(this).attr('disabled')!='disabled'){
            fn(this);
        }
    });
    return $(this);
}
$.fn.btnToggle = function(){ //toggle disable/enable
    if($(this).attr('disabled')=='disabled'){
        $(this).removeAttr('disabled');
    }
    else{
        $(this).attr('disabled','disabled');
    }
    return $(this);
}

我也在扩展Array原型(prototype):
    Array.prototype.isArray = true; //this allows us to say if(variable.isArray) to detect arrays

有任何想法吗?我对此感到无比沮丧。任何帮助或指示将不胜感激。

最佳答案

问题显然是jQuery,jQuery UI或它们的配对的版本问题。我正在使用jQuery 1.7.1和jQuery UI 1.8.1。使用来自Google的AJAX库后,问题消失了。 Nodetitle仅出现在UI库中,因此我假设其中很大。对于任何jQuery开发人员,我建议在UI和 Vanilla 之间进行某种包控制。也许可以通过使用AJAX调用将UI移植到浏览器中,以使UI始终与适当的原始程序包匹配?无论如何,解决了。

09-10 10:27
查看更多