0

Hi,

I am struggling with this..I have multiple images and data with same class. As I click on a link with class
single_image it should pop up the corresponding div.
but its not working every time i click it shows me the same image.
I have tried using $("a.single_image").each( function () { $(this).fancybox({ }]; }];but this is also not working
refer code below..

jquery script:

<script type="text/javascript">
    $("a.single_image").fancybox({
        'href'   : '#data',
        'titleShow'  : false,
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic'
    });
</script>

php script:

while($row = mysql_fetch_array($query)) {
echo "<a class='single_image' href='#data'>" . $row[4] . "</a><br/>";
        echo '<div style="display:none"><div id="data">
        <img src="../word/wordpress/wp-content/plugins/mall_events/images/' . $row[9] . '"/><br/> 
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div></div>';
}

Thanks in advance.

2
Contributors
2
Replies
21
Views
4 Years
Discussion Span
Last Post by code_rum
0

@code_rum

but its not working every time i click it shows me the same image.

I think you modify the code little too much.

Take a look here:

http://fancybox.net/howto

2

I worked on it here's the code.

jquery script:

<script type="text/javascript">

function load_url_popup(data){

    $("a.single_image").fancybox({
        'href'   : data,
        'titleShow'  : false,
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic'
    });
}
</script>

php script:

while($row = mysql_fetch_array($query)) {

    $file[$i] = date('m', strtotime($row[3]));
    $tile[$i] = date('Y', strtotime($row[3]));
    if ($file[$i] == $month && $tile[$i] == $year) {
        echo $file[$i] . " ";
        echo "<a class='single_image' href='javascript:vois{0}' onclick='load_url_popup(\"#data_".$i."\")'>" . $row[4] . "</a><br/>";
        echo '<div style="display:none"><div id="data_'.$i.'">
        <img src="../word/wordpress/wp-content/plugins/mall_events/images/' . $row[9] . '"/><br/> 
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div></div>';
        echo "<img src='../word/wordpress/wp-content/plugins/mall_events/images/thumbs/" . $row[9] . "'/><br/>";
        echo $row[5] . "<br/>";
    }
    $i++;
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.