如何正确克隆(jQuery)通过 PIE 应用样式的元素?
我一直在一个新项目(专门针对IE8+),但是,在尝试克隆应用了 PIE 样式的元素时遇到了麻烦。
我在 此处 找到了一个 jsfiddle 来说明问题,欢迎输入(甚至是其他类似的 PIE 方法/替代方案) - 但是,.htc
文件不能跨域引用,因此这个小提琴仅包含我使用的实际标记和 CSS。
任何帮助表示赞赏。可能是什么原因造成的,是否有潜在的解决方法?
干杯, 人民
I have been using the .htc
version of PIE successfully on a new project (that will specifically target IE8+), however, I'm having trouble when trying to clone an element that has PIE-style applied to it.
I got a jsfiddle illustrating the problem here, and input is welcome (even other, similar approaches/alternatives to PIE) - however, .htc
files cannot be referenced cross-domain, so this fiddle just contains the actual markup and CSS I use.
Any help is appreciated. What could be causing this, is there a potential workaround?
Cheers,
peol
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
克隆具有 PIE 后代的元素时会遇到两个问题:
因此,为了进行正确的克隆,我们需要摆脱两者。第一个可以通过暂时将每个 PIE 元素的行为样式属性设置为“无”来完成,然后克隆并恢复它。将其设置为“none”会触发 PIE 的清理方法,该方法会删除所有 VML 元素。第二项必须手动完成,因为 PIE 不会自动删除 _pieId 属性。这两个脚本都很容易编写。
下面是一个自定义 jQuery 扩展,它在我有限的测试中处理此问题:
然后,您将调用 cloneWithPIE 方法,就像调用普通的克隆方法一样:
希望这对您有用。
There are two issues that are encountered when cloning elements with PIE'd descendants:
So in order to do a proper clone, we need to get rid of both. The first can be done by temporarily setting the behavior style property of each PIE'd element to 'none' while cloning and restoring it afterward. Setting it to 'none' triggers PIE's cleanup methods which remove all the VML elements. The second item has to be done manually, as PIE does not remove the _pieId attributes automatically. Both of these are easy enough to script.
Here is a custom jQuery extension that handles this in my limited testing:
You then would call the cloneWithPIE method just like you would call the normal clone method:
Hope that works for you.