jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了javascript – jQuery Dialog奇怪的错误大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
到目前为止,这是我遇到的最令人烦恼和奇怪的问题.这是荒谬的基本(墨菲法律错误之一)

我有一个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,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原型:

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.从谷歌使用AJAX库后,问题就消失了. Nodetitle只出现在UI lib中,所以我假设那里的大谎言.对于任何jQuery开发者,我建议在UI和vanilla之间进行某种包控制.也许UI可以通过使用AJAX调用移植到浏览器中,以便UI始终与正确的vanilla包匹配?无论如何,解决了.

大佬总结

以上是大佬教程为你收集整理的javascript – jQuery Dialog奇怪的错误全部内容,希望文章能够帮你解决javascript – jQuery Dialog奇怪的错误所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。