1

私はphpを使用してテーブルを作成していますが、これがテーブル本体の作成方法です。

while (mysqli_stmt_fetch($stmt)) {      
    // Create Table Body
    $html .= "<tr>\n";
    $html .= "  <td>$title</td>\n";
    $html .= "  <td>$date</td>";                            
    $html .= "  <td align='center'>\n";
    $html .= "      <a href='#'>\n";
    $html .= "          <span class='view' title='View This Comment'></span>\n";
    $html .= "      </a>\n";
    $html .= "  </td>\n";                           
    $html .= "  <td class='td_catchall' align='center'>\n";
    $html .= "      <a href='#'>\n";
    $html .= "          <span class='edit' title='Edit This Comment'></span>\n";
    $html .= "      </a>\n";
    $html .= "  </td>\n";                       
    $html .= "  <td align='center'>\n";
    $html .= "      <a href='#'>\n";
    $html .= "          <span class='delete' title='Delete This Comment'></span>\n";
    $html .= "      </a>\n";
    $html .= "  </td>\n";
    $html .= "</tr>\n"; 
} 

このテーブルを使用すると、各コメントを表示、編集、および削除するための 3 つの列があります。アクションごとにjqueryダイアログをトリガーしたい。ビューダイアログで動作するようにしようとしました。ただし、リンクごとに 1 つのコメントのみが表示されます。このようなwhileループでダイアログを表示するコードを追加しました-

//Create View Blog Dialog Box 
$viewBlog  = "<div id='dialog-view'>\n";
$viewBlog .= "      <h2>$title</h2>\n";
$viewBlog .= "  <p>$date</p>\n";
$viewBlog .= "  <p>";
$viewBlog .= "          <img src='".UPLOAD_DIR.$userName."/".$image."' />";
$viewBlog .= "      $comment</p>";
$viewBlog .= "</div>\n";

アップデート

私のjQuery -

$( "#dialog-view" ).dialog({
        autoOpen: false,
        height: 450,
        width: 650,
        modal: true,
        buttons: {
            Cancel: function() {
            $( this ).dialog( "close" );
            }
        }, 
        position: { 
            my: "center top", 
            at: "center top",
            of: "#content"
        }
}); 

$( ".view" ).click(function() {
    $( "#dialog-view" ).dialog( "open" );
}); 

誰でもこれを理解するのを助けることができますか? ありがとうございました。

4

1 に答える 1

0

while ループ内にダイアログのコードを追加すると、複数のダイアログが作成されます。しかし、それらはすべて同じ iddialog-viewです。そのため、常に最初に出現したものが読み込まれます。

次のように変数を追加することで、特定のダイアログを開くことができeg: $iます

//Create View Blog Dialog Box 
$viewBlog  = "<div id='dialog-view-$i'>\n";

次に、最初の while ループで、

<span class='view' onclick='$(\"#dialog-view-$i\").dialog(\"open\");' title='View This Comment'></span>\n";
于 2013-08-23T17:17:26.580 に答える