0

Javascript/jQuery のブートストラップのフレームワークから popover 要素を使用しようとしていますが、while ループの最初のものでのみ機能します。それらすべてに対して機能させるにはどうすればよいですか?

どうしてこれなの?これを少し理解しようとしています...

<?php
require 'include.php';
session_start();

    $selectBets = $dbc->query("SELECT * FROM `bets` ORDER BY `bid` DESC LIMIT 10");
?>
<style type="text/css">
#hash_text {
    font-size: 3.8px;
}
</style>
<table class="table table-striped table-bordered table-hover">
                <thead>
                  <tr>
                    <th>Bet Number</th>
                    <th>Amount</th>
                    <th>Send Address</th>
                    <th>Time Created</th>
                    <th>Time Expires</th>
                    <th>Chance to Win</th>
                    <th>Payout Multiplier</th>
                    <th>Final Profit</th>
                    <th>Server Hash</th>
                  </tr>
                </thead>
                <tbody>
                <?php while($BetsArray = $selectBets->fetch()) { ?>
                  <tr>
                  <td><?php echo $BetsArray['bid']; ?></td> 
                  <td><?php echo $BetsArray['amount']; ?></td> 
                  <td><?php echo $BetsArray['deposit_address']; ?></td> 
                  <td><?php echo date('m/d/Y - H:i:s', $BetsArray['time_created']); ?></td> 
                  <td><?php echo date('m/d/Y - H:i:s', $BetsArray['time_expires']); ?></td> 
                  <td><?php echo $BetsArray['win_chance']; ?></td> 
                  <td><?php echo $BetsArray['multiplier']; ?></td> 
                  <td><?php echo $BetsArray['profit']; ?></td> 
                  <td><a id="hash" data-container="body" data-toggle="popover" data-placement="right">Click here for Server Hash</a></td>
                  </tr>
                <?php } ?>
                </tbody>
              </table>
              <script type="text/javascript">
              $(function() {
                $('#hash').popover({
                    html: true,
                    placement: 'right',
                    content: '<?php echo '<span id="hash_text">' . hash('sha512', $BetsArray['number'] . '-' . $_SESSION['client_seed']) . '</span>'; ?>'
                });
              });
              </script>
4

1 に答える 1

1

IDを複製してポップオーバー要素を作成しています。それをクラスに変更して、動作することを確認してください。

<a id="hash" data-container="body" data-toggle="popover" data-placement="right">Click here for Server Hash</a>

id セレクターを使用してポップオーバーにバインドすると$('#hash')、DOM に表示される id を持つ最初の要素のみが選択されるため、表示されている動作になります。

クイックフィックスを配置したい場合は、属性セレクターを使用して、このように ID を選択できます。

$('[id=hash]').popover({
                    html: true,
                    placement: 'right',
                    content: '<?php echo '<span id="hash_text">' . hash('sha512', $BetsArray['number'] . '-' . $_SESSION['client_seed']) . '</span>'; ?>'
});

でも絶対そんなことしない

于 2013-09-20T03:24:40.600 に答える