Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/10/2012, 15:50
Avatar de ClubIce
ClubIce
 
Fecha de Ingreso: diciembre-2008
Mensajes: 216
Antigüedad: 15 años, 4 meses
Puntos: 2
Evento agregado dinamicamente no se activa.

Esto solo me pasa en este fracmento de codigo, en en otras partes si me funciona correctamente el AddEventListener, pero aqui no, he intentado cambiando el evento por 'click' o 'mouseover', pero no funciona.

Código Javascript:
Ver original
  1. var WindowIndex = new Class ({
  2.   initialize:function (width,_size,items) {
  3.     this.items = []
  4.     with (this.insertOption = $C('option')) {
  5.       innerHTML = "Insertar..."
  6.     }
  7.     with (this.insertSelect = $C("select")) {
  8.       setAttribute("class","box-index")
  9.       appendChild(this.insertOption)
  10.       for (var i in items ) {
  11.         var item = items[i]
  12.         with (this.items[item[0]] = $C('option')) {
  13.           value = item[0]
  14.           innerHTML = item[1]
  15.         }
  16.         appendChild(this.items[item[0]])
  17.       }
  18.       style.width = width + "px"
  19.     }
  20.     this.insertSelect.addEventListener("change",function () {
  21.         alert("deberia suceder algo")
  22.       })
  23.     with (this.itemSelector = $C("select")) {
  24.       setAttribute("class","box-index-selector")
  25.       style.width = width + "px"
  26.       size = _size
  27.     }
  28.     with (this.object = $C("div")) {
  29.       style.float = "left"
  30.       style.marginRight = "5px"
  31.       appendChild(this.insertSelect)
  32.       appendChild(this.itemSelector)
  33.     }
  34.   }
  35. })

NOTA: $C(): crea un objeto DOM