jQuery 1.8.2 +非当前jQuery UI =打破了externalWidth和externalHeight [英] jQuery 1.8.2 + noncurrent jQuery UI = outerWidth and outerHeight broken

查看:112
本文介绍了jQuery 1.8.2 +非当前jQuery UI =打破了externalWidth和externalHeight的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是对错误关闭的问题的重做: jQuery 1.8外部高度/宽度不起作用

This is a re-do of a question that was closed erroneously: jQuery 1.8 outer Height/Width not working

我遇到了同样的问题. outerWidthouterHeight,现在返回jQuery对象而不是数字.

I'm hitting the same issue. outerWidth and outerHeight and now returning the jQuery object instead of numbers.

我们使用的是2012年1月10日发布的jQuery UI 1.8.17.它不是一个超旧的版本,因此我觉得其他人也会看到这一点.由于某些糟糕的jQuery ui插件,我们被锁定在此版本中,因此当前无法选择升级.

We are using jQuery UI 1.8.17, released Jan 10, 2012. It is not a super old version so I have a feeling other people will see this. We are locked into this version because of some terrible jQuery ui plugins, so upgrading is not currently an option.

如果找到解决方案,我将回答这个问题.

If I find a solution I will answer this question.

这里有个小提琴,说明了这个问题 http://jsfiddle.net/delvarworld/yxDHu/ (在管理资源"中添加了jQuery UI版本)

Here's a fiddle demonstrating the problem http://jsfiddle.net/delvarworld/yxDHu/ (jQuery UI version added in "manage resources")

更新:这是因为jQuery UI中的这一行:

Update: It's because this line in jQuery UI:

return orig[ "outer" + name ].call( this, size );

在jQuery 1.8.2中错误地触发了这种情况:

is erroneously triggering this condition in jQuery 1.8.2:

var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),

因为即使未定义size,也将检查arguments.length.可链接的在这里应该是错误的.您可以传入undefined,它仍然会使参数成为长度为1的对象.有人需要阅读其JS;)

because even though size is undefined, the check is for arguments.length. chainable should be false here. You can pass in undefined and it will still make arguments an object with length 1. Someone needs to read up on their JS ;)

推荐答案

一个简单的解决方案似乎只是传入false

A simple solution seems to be just passing in false

$(document.body).outerWidth(false);

或者,如果您想要边距,则为true,但是如果您传递的是true,则好像您不会遇到此bug.

Or, true if you want the margins, but if you were passing in true it looks like you would not have encountered this bug.

这篇关于jQuery 1.8.2 +非当前jQuery UI =打破了externalWidth和externalHeight的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆