Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/08/2010, 10:10
Avatar de destor77
destor77
 
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 5 meses
Puntos: 43
problema con seleccionar todos los checkbox

Buenas,
estoy teniendo problemas para usar una función que permita seleccionar todos los checkbox de un formulario.
Mi formulario usa el css y el js jNice (que es el que me genera el problema), el css del checkbox es:
Código CSS:
Ver original
  1. /* -------------
  2.  * Checkboxes
  3.  * ------------- */
  4. .jNiceCheckbox {
  5.     background: transparent url(../images/checkbox.gif) no-repeat center top;
  6.     vertical-align: middle;
  7.     height: 16px;
  8.     float: left;
  9.     margin: 0 10px 0 0;
  10.     width: 14px;
  11.     display:block;/*display: -moz-inline-block;*/
  12. }
  13.  
  14. /* -------------
  15.  * Checked - Used for both Radio and Checkbox
  16.  * ------------- */
  17. .jNiceChecked { background-position: center bottom;}

el js para darle estilo es que esta en el archivo jNice.js:
Código Javascript:
Ver original
  1. $('input:checkbox', this).each(function(){
  2.         $(this).addClass('jNiceHidden').wrap('<span></span>');
  3.         var $wrapper = $(this).parent();
  4.         $wrapper.prepend('<a href="#" class="jNiceCheckbox"></a>');
  5.         /* Click Handler */
  6.         $(this).siblings('a.jNiceCheckbox').click(function(){
  7.             var $a = $(this);
  8.             var input = $a.siblings('input')[0];
  9.             if (input.checked===true){
  10.             input.checked = false;
  11.             $a.removeClass('jNiceChecked');
  12.             }
  13.             else {
  14.             input.checked = true;
  15.             $a.addClass('jNiceChecked');
  16.             }
  17.             return false;
  18.         });
  19.         /* set the default state */
  20.         if (this.checked){
  21.             $('a.jNiceCheckbox', $wrapper).addClass('jNiceChecked');
  22.         }
  23.         });

y mi funcion que esta dentro del archivo funciones.js es:
Código Javascript:
Ver original
  1. $(document).ready(function(){
  2.         //checkbox para los permisos de usuarios
  3.     $("input[name=checktodos]").change(function(){
  4.     $('input[type=checkbox]').each( function() {
  5.         if($("input[name=checktodos]:checked").length == 1){
  6.         this.checked = true;
  7.         } else {
  8.         this.checked = false;
  9.         }
  10.     });
  11.     });
  12.  
  13. });

si en el formulario saco esto class="jNice" la funcion anda perfectamente pero si le agrego la clase para darle diseño al formulario deja de funcionar.
Como podría solucionarlo?
Desde ya muchas gracias