开发者

<body></body> tags are being inserted into the head of my document from jQueryMobile

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

<body></body> tags are being inserted into the head of my document from jQueryMobile


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 edits

So 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 called hasAttr 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜