2

好的,所以我正在使用颜色框弹出由 PHP 生成的动态数据的窗口。下面是我的 php 代码...当我单击链接时,窗口会弹出数据...但是如果我单击再次相同的链接,窗口没有得到信息,我在控制台中得到这个,a.removeEventListener is not a function第二次点击颜色框的链接来显示..第一次工作..可能出了什么问题?

jQuery(document).ready(function() {
   var id_form;
            var url;
            $("a.madcomment").click(function(e) {
               e.preventDefault();
             id_form = $(this).attr('id');
             url ="#madcomment_menu"+id_form; 
             $("a.madcomment").colorbox({inline:true, width:"350px", href:url});
             });


    });

    <?php
    $select  = "SELECT * FROM COMMENTS INNER JOIN Twitter_Data ON Twitter_Data.screen_name=Comments.Twitter WHERE Category ='Comments'";
          $result = mysql_query($select);
          $result_count = mysql_num_rows($result);
          echo " <table border =\"0\">";
          echo "<tr>";
          $user_array = array();
          $counter = 0;
          if($result_count > 0) {
            while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {  
     echo  "<div id ='scoring_scale' class='madscore".$row['ID']."' style='display:none;'>";
    echo "<div id='madcomment_menu".$row['ID']."' style='padding:10px; background:#fff;'>";
              echo "<a id='".$row['ID']."' class='green_circle' href='#'> +3 </a>";
              echo "<a id='".$row['ID']."' class='orange_circle' href='#'> +1 </a>";
              echo "<a id='".$row['ID']."' class='red_circle' href='#'> -1 </a>";
              echo "<a id='".$row['ID']."' class='brown_circle' href='#'> -3 </a><br />";
              echo"<form>";
              echo "<textarea id='text".$row['ID']."'rows='5' cols='33'>";
              echo "-";
              echo "</textarea>";
              echo"<button id='button".$row['ID']."'class='button_madscore'> MadComment </button>";
              echo "</form>";
              echo "</div>";
              echo "</div>";
    }

    }

    // Here is the link that will generate the COLORBOX pop-up

    echo "<a id='".$row['ID']."'class=' madcomment' href='madcomment_menu".$row['ID']."'><img src='images/madcomment.png' /> </a>";
    ?>
4

1 回答 1

0

您每次在锚点单击时都绑定您的颜色框,因此为了防止这种情况将您的颜色框代码替换为以下内容:

$.fn.colorbox({inline:true, width:"350px", href:url});

这将解决您的问题。

于 2013-08-18T04:27:35.630 回答