Note that there are some explanatory texts on larger screens.

plurals
  1. POColor box open more than 1 time in ajax generated content
    text
    copied!<p>So basically, i have a series of content which upon click, color box will show up.</p> <pre><code>echo '&lt;div id=scrollimgforplaces&gt;'; while ($row = mysql_fetch_array($result)) { echo "&lt;a class='ajax' href='image_color_box.php?id=".$row['id']."' title='Utourpia'&gt;&lt;/a&gt;"; echo '&lt;a class="ajax" href="login_for_color_box.php" title="Login"&gt;&lt;/a&gt;'; } echo '&lt;/div&gt;'; </code></pre> <p>For the above static content, I call colorbox by using the below code:</p> <pre><code>$(".ajax").colorbox(); </code></pre> <p>Next, I will be generating some of the dynamic content similar to this, to make colorbox works, i put the below codes in my ajax:</p> <pre><code>$.ajax({ type: "POST", url: "data.php", data:data, success: function(res) { var $html = $(res); $html.find('a.ajaxdynamic').colorbox(); $('#scrollimgforplaces').append($html); } }); </code></pre> <p>And my dynamic content is as follows:</p> <pre><code>while ($row = mysql_fetch_array($result)) { echo "&lt;a class='ajaxdynamic' href='image_color_box.php?id=".$row['id']."' title='Utourpia'&gt;&lt;/a&gt;"; echo '&lt;a class="ajaxdynamic" href="login_for_color_box.php" title="Login"&gt;&lt;/a&gt;'; } </code></pre> <p>However, when I run the above codes, and i do some action, i.e. scroll down so that the dynamic content will show up. When i click the colorbox, it will show up two times, instead of once. Any idea what happened?</p> <p>Demo page: <a href="http://utourpia.me/php/dreamtrip.php" rel="nofollow">http://utourpia.me/php/dreamtrip.php</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload