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