Pregunta

Tengo un poco de sencillo creado con XAJAX, que sustituye a la innner HTML de un control select con algunas opciones creadas por un script php.

Este es fino y elegante, en Firefox, pero no funciona en IE7.

Buscando en la XAJAX foros he encontrado este lo que básicamente dice que "no realmente funcionan en IE, el uso de un div y reemplazar el código HTML interno de que, con la plena instrucción select"

Hecho esto, y está bien, excepto que tenía un selector de jQuery trabajando en el control select, que ahora ya no funciona.

Alguien tiene alguna idea, o puede alguien que me señale una buena jQuery ejemplo de cómo hacer el ajax de bits usando jQuery, así que puede abandonar la XAJAX en total?


EDITAR:

<div id=imgselect>
  <select id="images">
   <option value="">Then select an image</option>
  </select>
</div>


Picture Preview:<br><br>

 <div class="img-preview" id='preview'></div>
 <script type='text/javascript'>
   $('#images').change(function() 
   {
     var image = $(this).val();
     var img = $('<img/>').attr('src', image);
    $('#preview').html(img);

    document.getElementById('picsmall').value = image;
    });
</script>

El problema viene cuando el contenido de la imgselect div es sustituida por la llamada AJAX

¿Fue útil?

Solución

Este es resuelto ahora el uso de la

$objResponse->script

comando

En aras de la exhaustividad y si alguien quiere ver en el futuro, tengo el original de la página configurar como arriba:

<div id=imgselect>
  <select id="images">
    <option value="">Then select an image</option>
  </select>
</div>

luego, en mi xajax archivo php que tengo

function getphotos()
{
    $objResponse = new xajaxResponse();
        //this include assigns all the options to the select controll into the $output var
    include "photos.photosselect.php";
    $objResponse->assign("imgselect", "innerHTML", "$output");
    $objResponse->script("$('#images').change(function() {var image = $(this).val(); var img = $('<img/>').attr('src', image); $('#preview').html(img); document.getElementById('picsmall').value = image;});");
    return $objResponse;
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top