【问题标题】:buttonset() span not working properly with IE7buttonset() span 在 IE7 中无法正常工作
【发布时间】:2012-05-22 21:22:35
【问题描述】:

我正在使用最新版本的 jquery,并用它作为主题的复选框列表。

每次用户点击按钮集跨度(就用户而言,这几乎是整个按钮)时,我都是 IE7,页面向上滚动大约 600 像素。

这确实不是一件好事,尤其是因为这些收音机位于页面下方很远且带有滚动条的位置,您能想象一下想要选择 60 个选项的用户吗?每次都必须向下滚动?

我对这些收音机只使用了这个:

$(".prettyme br").replaceWith(''); //fix RadioButtonList Bug
$(".prettyme").buttonset();

你可以在http://www.apff.org/fr/inscriptions.aspx?i=18看到我的错误的实时版本

使用 IE7,向下滚动并单击数字前面带有 C- 的众多复选框按钮之一。

我知道它与位于创建按钮图像的标签内部的跨度有关,如果我在其中一个跨度上附加点击事件并使其返回 false,我不会再出现这种行为。(它会停止复选框从被选中和取消选中标签点击然而)

如何阻止这种恶劣的 Jquery 行为?

【问题讨论】:

  • 公平;这听起来更像是地狱般的 IE7 行为。

标签: jquery jquery-ui internet-explorer-7


【解决方案1】:

我通过在单击按钮之前保存滚动条位置并稍后将滚动条恢复到其初始位置来修复此错误。

/*
 * The code below fixes a bug in Internet Explorer.
 * The bug happens when a gender button is being clicked,
 *  and scrolls the page down.
 * Don't replace it by 'return false' or 'preventDefault()',
 *  it will prevent the radio button from being selected.
 */
$('.ui-button').live("click", function(event) {
  // save the vertical scrolling bar's position
  scrollTop = $(window).scrollTop();

  $('.box_radio').click(function(){
    // bring the scrolling bar at its initial position
    if (scrollTop)
      $(window).scrollTop(scrollTop);
    scrollTop = false;
  });
});

box_radio 是按钮的父元素。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-13
    • 2010-09-16
    • 2012-06-12
    • 2011-11-02
    • 1970-01-01
    • 2013-04-07
    • 1970-01-01
    • 2011-07-10
    相关资源
    最近更新 更多