【问题标题】:why is my context selector and .buttonset() taking so long in ie为什么我的上下文选择器和 .buttonset() 在 ie 中花了这么长时间
【发布时间】:2012-09-11 00:49:30
【问题描述】:

所以我认为这是我做错了。它太慢了,即这一定有什么根本性的问题。

Le HTML

<div id='mother'>

  <div id="radio">
    <input type="radio" id="radio1" name="radio" />
      <label for="radio1">Choice 1</label>
    <input type="radio" id="radio2" name="radio" checked="checked" />
      <label for="radio2">Choice 2</label>
  </div>

  <div id="radioTwa">
    <input type="radio" id="radioTwa1" name="radioTwa" />
      <label for="radioTwa1">Choice 1</label>
    <input type="radio" id="radioTwa2" name="radioTwa" checked="checked" />
      <label for="radioTwa2">Choice 2</label>

  </div>

  <div id="check">
    <input type="checkbox" id="check1" name="check" />
      <label for="check1">Choice 1</label>
    <input type="checkbox" id="check2" name="check" checked="checked" />
      <label for="check2">Choice 2</label>

  </div>

</div>​​​​​​​​​​​​

Le JQuery/JQuery UI

    var mother = $('​​​​​​​​​​​​​​#mother');
​    mother.find('#radio').buttonset();​​​​​​
    mother.find('#radioTwa').buttonset();
    mother.find('#check').buttonset();

    var mother = $(​​​​​​​​​​​​​​'#mother');
​    $('#radio', mother).buttonset();​​​​​​
    $('#radioTwa', mother).buttonset();
    $('#check', mother).buttonset();

这两者都会让 IE 8 崩溃并让它哭泣。为了将一些事情扼杀在萌芽状态,我故意使用母亲的语境。我没有每个单选框的唯一 ID,我计划使用上下文来选择它们,因为页面上的数字 'mother' 类型 div 虽然我使用的每个母 div 元素只有大约 8 或 9 个元素它。有没有办法在 IE 8 中使用足够快的上下文来选择它不会停止?

【问题讨论】:

  • 使用 ID 选择器时不需要上下文或 .find()。最快的总是只做$('#radio')。不知道为什么 buttonset() 这么慢...
  • 谢谢 Nal,我知道我不必在我提供的示例中使用上下文选择器,但是使用我正在处理的代码,它是如何设置和更改它的将是相当大的工作量。正如您所指出的, .buttonset() 才是真正导致问题的原因。
  • 你总共有多少个按钮? stackoverlow 上似乎有一些关于慢速按钮集的规定。我还找到了bugs.jqueryui.com/ticket/5454
  • 页面上的简答 60-120。在任何给定的收音机或检查中只有 2 个按钮,在任何给定的“母亲”div 中有 6 个按钮,4 个输入:收音机 2 个输入:检查。还有一个输入:'母亲' div 中的文本。根据内容,有 10-20 个“母亲”div。所以我认为这个错误可能是我遇到的。我修复了我的代码中的另一个错误,现在它没有那么慢以至于导致页面停止,但仍然有点哭。
  • Hrm,这不是一个巨大的数额,但仍然很多。此解决方案可能对您有用stackoverflow.com/questions/12060742/…

标签: javascript jquery html jquery-ui jquery-ui-button


【解决方案1】:

你总共有多少个按钮? stackoverlow 上似乎有一些关于慢速按钮集的规定。我还发现了 bugs.jqueryui.com/ticket/5454 – Nal

【讨论】:

  • 我很确定这也是 Nal 链接的错误。
猜你喜欢
  • 1970-01-01
  • 2010-10-07
  • 1970-01-01
  • 2013-08-26
  • 2017-11-15
  • 1970-01-01
  • 1970-01-01
  • 2021-06-01
  • 1970-01-01
相关资源
最近更新 更多