I have just started getting a very strange error when using jQueryMobile for my mobile website/app
edit i am adding a picture, probably a lot easier to understand the question
edit2 i have found the issue. still curious as to why this is the way it is
if you wish to see the original post please read the editsSo in my master.js file I had the following code
Object.prototype.hasAttr = function(attr) {
var _attr;
if(this.attr) {
_attr = this.attr(attr);
} else {
_attr = this.getAttribute(attr);
}
return (typeof _attr !== "undefined" && _attr !== false && _attr !== null);
};
If I remove the code everything works! I have also run the code through jsLint and it does not contain errors.
I've looked in the docs and the jQueryMobile framework does not have a function calledhasAttr
so where is the conflict?
PLEASE NOTE: THIS FUNCTION IS NEVER ACTUALLY RUN! JUST INCLUDING IT BREAKS TH开发者_运维百科INGS
I think I see the problem. You are mixing and matching Jquery with prototype here. I think the function getAttribute is the problem, because that is not a jquery function and yet it is trying to act on a jquery object here
Object.prototype.hasAttr = function(attr) {
var _attr;
if(this.attr) {
_attr = this.attr(attr);
} else {
_attr = this.getAttribute(attr);
}
return (typeof _attr !== "undefined" && _attr !== false && _attr !== null);
};
conflicting code was the issue.
精彩评论