Cheers Karl,

well my situation is slightly different compared to that I described
above:

1) I have an iframe I use to upload images under a form
2) I have the list of the uploaded images over the iframe
3) once an image is uploaded successfully it gets appended to the list
of the images


The script responsible for this is:

------------------------------------
<html><head>
<?php echo $javascript->link(array($wbConf['js']['jquery']));?>
<?= $javascript->link(array('shared/jquery.fancybox-1.0.0'))?>
<script type="text/javascript">
var $j = jQuery.noConflict();
var par = window.parent.document;
var message = '<div class="error-message"><?=$message?></div>';

<?php
    if($success == true){
?>

    //creo HTML nuova immagine
    var img_html = '<?= $utility->imgup($class. '/'.$foreignKey.'/
small/m_' . $imgName, array('class'=>'jt', 'title'=>'immagine',
'alt'=>'immagine'))?>';

    //creo HTML menu nuova immagine
    var menu = '<ul class="menu">\n'
    +'\t\t<li>\n'
    +'        <a rel="fancybox" href="<?=('/img/../uploads/'.$class.
'/'.$foreignKey.'/' . $imgName)?>" rel="facybox">\n'
    +'          <img title="preview" alt="preview" src="<?=$this->base?
>/img/admin/view.png"/>\n'
    +'        </a>\n'
    +'    </li>\n'
    +'\t\t<li>\n'
    +'        <a onclick="deleteThumb(\'<?=$this->base?>/<?
=Configure::read('Routing.admin')?>/attachments/deleteajax/\', <?=
$last_id?> ,\'<?=$class?>\' ,<?=$foreignKey?>); return false;"
href="#mythumbs">\n'
    +'          <img title="Delete" alt="Delete" src="<?=$this->base?>/
img/admin/dustbin.gif"/>\n'
    +'        </a>\n'
    +'    </li>\n'
    +'<li><a onclick="setThumb(\'<?=$this->base?>/<?=Configure::read
('Routing.admin')?>/attachments/set_thumbajax/\', 1, <?=$last_id?> ,
\'<?=$class?>\' ,<?=$foreignKey?>); return false;" href="#mythumbs">
\n'
    +'fai princ</a></li></ul>';


    var htmlToInsert = img_html + menu;//let's set par to the parent
document

    //aggiungi class a div immagine per sorting
    $j('#thumbs', par).children('.thumb:last').attr('id', '<?=$order?>-
<?=$last_id?>');
    //removes the spinner to the last uploaded image and replaces it
with the new img and menu
    $j('#thumbs', par).children('.thumb:last').html('').append
(htmlToInsert);
        $j('#thumbs a...@rel*=fancybox]', par).fancybox();
<?php

}
else{
?>
    var htmlToInsert = message;
    $j('#thumbs', par).children('.thumb:last').remove();
<?php
}
?>
    </script>
    </head>
</html>
------------------------------------


After the upload of 1 ore more images:

- fancybox still works but only on the images already present
- fancybox doesn't work on the newly injected images

I refer to fancybox here, just because I use it, but I experienced the
same behavior with cluetip using the above described technique.

Any clue on how to apply the .fancybox function to the newly injected
images?

Dan

Reply via email to