Cufon、cufontext 在 jQuery 克隆 IE7 上中断
我的 jQuery 滑块中有 5 个元素,然后将滑块元素克隆一次,以便有足够的元素用于循环连续滑动。
这是我用来克隆元素的代码:
$mo.prepend($mo.children().clone().removeClass('active'));
在第一个实例中,Cufon 工作得很好,但是在克隆之后,它似乎通过添加间距并将 cufontext 保留在元素后面而破坏了它的布局。
这是一个可以更好地描述问题的图像:
我已尝试以下方法来尝试引用并重新-设置 cufon 文本;
$mo.prepend($mo.children().clone().removeClass('active').show(function(){
Cufon.refresh();
}));
我也尝试过使用 Cufon.replace()
重新定义 cufon 有没有人以前遇到过这个问题,如果有的话你是如何解决的?
我注意到,一旦克隆完成,cufontext 第一个实例上的 CSS 属性就会在传输过程中丢失。
请注意,这些问题仅在 IE7(可能更低)中出现,
我已经复制了该问题,在 JSBIN 中,它完全符合我网站上发生的情况,
I have 5 elements in a jQuery slider, the slider elements are then cloned once so there are enough elements for a circular continuous slide.
Here is the code i am using to clone my elements:
$mo.prepend($mo.children().clone().removeClass('active'));
On the first instance the Cufon works great, but after it's been cloned it seems to break it's layout, by adding spacing and keeping the cufontext behind the element.
Here is an image to better describe the issue:
I have tried the following to try and refersh and re-instate the cufon text;
$mo.prepend($mo.children().clone().removeClass('active').show(function(){
Cufon.refresh();
}));
i have also tried re-defining the cufon with Cufon.replace()
has anyone had this issue before, and if so how did you fix it?
I have noticed the CSS attributes that are on the first instance of the cufontext are lost in-transit once the clone has been completed.
Note these issues are only in IE7 (and probably lower)
I have replicated the issue, in JSBIN it does exactly what is happening on my site,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了让 IE7 在移动元素时正常工作,我必须交换事物的顺序并使用
prependTo
而不是prepend
。也许这里值得一试。To get IE7 working when moving elements around, I've had to swap the order of things and use
prependTo
instead ofprepend
. Maybe worth a try here.所以我想出了如何做到这一点,我意识到 jQuery 也从 HTML 复制了 cufon 元素,所以当我恢复 cufon.register 或刷新时,它会尝试将其应用到>cufon 元素已注册。
为了解决这个问题,我只是在调用
.clone()
之前清理了对象。您可能会清理与我不同的对象,但是嘿它有效,所以这是我使用的代码。
http://jsbin.com/awupuw/9 ->工作示例
So i figured out how to do this, i realized that jQuery was also copying the
cufon
elements from the HTML, so when i reinstated a cufon.register or refresh it would try to apply it to thecufon
elements already registered.To resolve this issue i simply cleaned out the objects before invoking
.clone()
.You will probably clean out your object different to me, but hey it works so here is the code that I used.
http://jsbin.com/awupuw/9 -> Working Example