1

這段JavaScript代碼不能在IE8工作,但在Firefox和谷歌Chrome瀏覽器的不工作:選中/取消選中所有複選框在IE8

<% 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> 

誰能幫助我?

+0

我討厭這麼說,但這是一個框架應該能夠爲你做的事情:確保這些東西能夠跨瀏覽器。否則,這只是另一個漏洞的抽象... – Robusto 2010-03-06 03:31:05

回答

1

IE是一款傑出的瀏覽器。我們必須關注代碼工作的複選框。跨瀏覽器的代碼是不匹配的IE瀏覽器,hehehhe

編輯:但取代'點擊''改變'也很好。

相關問題