views:

250

answers:

1

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("candidato_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?

A: 

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.

nanda