开发者

Check / uncheck all checkboxes doesn't work in IE8

开发者 https://www.devze.com 2022-12-21 22:29 出处:网络
This javascript code does not work in IE8, but works in Firefox and Google Chrome: <% content_for :head do %>

This javascript code does not work in IE8, but works in Firefox and Google Chrome:

<% content_for :head do %>
  <script type="text/javascript">
    document.observe("dom:loaded", function(){
      // Observe toggler
      $('toggle_all').observe('change', function(){
        var toggle = $('toggle_all').checked;
        $$('.check_boxes').each(function(check){
          check.checked = toggle;
        });
      })
    })
  </script>
<% end %>

<table>
<tr>
    ...
    <th><%= check_box_tag "toggle_all", 1, false %></th>
    ...
</tr>

<% reset_cycle %>
<% @estudantes.each do |estudante| %>
  <tr class="<%= cycle("even", "odd") -%>">
    ...
    <td><%= check_box_tag("candid开发者_JAVA百科ato_ids[]", estudante.id, 
      (checked = true if @vaga.candidato_ids.include?(estudante.id)), :class => 'check_boxes' ) %></td>
    ...
  </tr>
<% end %>
</table>

<%= submit_tag t('others.call', :item => 'vaga') %>
</form>

Can anyone help me?


IE is a browser outstanding. We must take the focus off the checkbox for the code work. Cross-browser code is no match for IE, hehehhe

EDIT: but replace the 'change' for 'click' works well, too.

0

精彩评论

暂无评论...
验证码 换一张
取 消