找出 jQuery Accordion 中的内容在更改事件时是否处于活动状态

发布于 2024-10-08 03:59:10 字数 874 浏览 2 评论 0原文

因此,我有一个 jQuery 手风琴,并且在内容区域中我使用图像创建了一些伪复选框。这在除 IE 6/7 之外的所有浏览器中都可以正常工作(不幸的是,我必须支持它)。发生的情况是,当我切换关闭/打开一个部分时,复选框会在内容通过动画完全打开之前出现。一种选择是禁用 IE 动画,但我不想这样做。相反,我希望有一种方法可以通过更改/更改启动功能显示/隐藏复选框。然而,似乎这样做,我需要在changestart函数中找出内容是否即将展开,或者即将折叠。如果它折叠起来,我需要在动画开始之前隐藏复选框。同样,在更改函数(完成后执行的函数)中,我需要查看内容是否已打开或关闭。如果它被打开,那么我们将要显示其中的复选框。这就是我现在正在尝试的,但它所能做的就是隐藏它,而且总是如此,所以我认为将其基于 .ui-accordion-content-active 类是行不通的:

$("#filter_accordion").accordion({
    header: "> div > h3",
    autoHeight: false,
    collapsible: true,
    active: false,
    change: function(event, ui) {
      if (ui.newContent.hasClass(".ui-accordion-content-active")) ui.newContent.find(".checkbox").show();
    },
    changestart: function(event, ui) {
      if (!(ui.newContent.hasClass(".ui-accordion-content-active"))) ui.newContent.find(".checkbox").hide();
    }
  });

任何帮助非常感谢!

So, I've got a jQuery accordion, and in the content areas I've created some pseudo checkboxes using images. This works fine in all browsers but IE 6/7 (which unfortunately, I have to support). What happens is when I toggle closed/open a section, the checkboxes appear before the content is completely opened via the animation. One option is to disable animations for IE, but I'd prefer not to do that. Instead, I was hoping there was a way I could show/hide checkboxes via the change/changestart function. However, it seems to do this, I need to find out in the changestart function if the content is about to expand, or about to collapse. If its collapsing, I'll need to hide the checkboxes before the animation begins. Likewise, in the change function (the one executed upon completion), I'll need to see if the content was opened or closed. If it was opened, then we'll want to show the checkboxes inside it. Here's what I'm trying now, but all its able to do is hide it, and it always does, so I'm thinking basing it on the .ui-accordion-content-active class isn't going to work:

$("#filter_accordion").accordion({
    header: "> div > h3",
    autoHeight: false,
    collapsible: true,
    active: false,
    change: function(event, ui) {
      if (ui.newContent.hasClass(".ui-accordion-content-active")) ui.newContent.find(".checkbox").show();
    },
    changestart: function(event, ui) {
      if (!(ui.newContent.hasClass(".ui-accordion-content-active"))) ui.newContent.find(".checkbox").hide();
    }
  });

Any help is greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

日记撕了你也走了 2024-10-15 03:59:10

好吧,从来没有得到任何回应,但万一其他人遇到它,我找到了解决方案。 UI 图标的可见性与另一个 IE 错误有关,即在展开/折叠部分时垂直移动图标。 ie67 只是我的模板中的一个布尔集,描述我们是否使用这些浏览器之一(IE 6/7),以防不明显。

$("#filter_accordion").accordion({
    header: "> div > h3",
    autoHeight: false,
    collapsible: true,
    active: false,
    changestart: function(event, ui) {
      if (ie67) {
        $("#filter_accordion .ui-icon").css("visibility", "hidden");
        ui.oldContent.find(".checkbox").hide();
        if (ui.newContent.is(":visible")) ui.newContent.find(".checkbox").hide();
      }
    },
    change: function(event, ui) {
      if (ie67) {
        $("#filter_accordion .ui-icon").css("visibility", "visible");
        if (ui.newContent.is(":visible")) ui.newContent.find(".checkbox").show();
      }
    }
  });

Well, never got any responses to this, but in case anyone else runs across it, I found a solution. The visibility of the UI icon has to do with another IE bug of shifting the icons around vertically when expanding/collapsing sections. ie67 is just a boolean set in my template describing if we're using one of those browsers (IE 6/7), in case that's not obvious.

$("#filter_accordion").accordion({
    header: "> div > h3",
    autoHeight: false,
    collapsible: true,
    active: false,
    changestart: function(event, ui) {
      if (ie67) {
        $("#filter_accordion .ui-icon").css("visibility", "hidden");
        ui.oldContent.find(".checkbox").hide();
        if (ui.newContent.is(":visible")) ui.newContent.find(".checkbox").hide();
      }
    },
    change: function(event, ui) {
      if (ie67) {
        $("#filter_accordion .ui-icon").css("visibility", "visible");
        if (ui.newContent.is(":visible")) ui.newContent.find(".checkbox").show();
      }
    }
  });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文