根据这个Post做的
http://stackoverflow.com/a/8983053/4196468
演示文档: http://plnkr.co/edit/NePR0BQf3VmKtuMmhVR7?p=preview
在演示里面完全没有问题,但是我实际使用的时候却根本没办法处理URL
讲一下我的情况,一个系统从数据库读取数据后通过While Loop 放到一个表格中,每行一个数据,每个数据有不同的信息,然后每个数据(每行)有一个可以删除的按钮来删除数据
每个删除是提交到另外一个PHP页面中解决的,PHP 页面通过GET(或者POST)来确认数据的ID然后删除这个数据
现在为了避免用户无意删除东西,需要加一个确认的步骤,按照上面那个StackOverflow处理了之后却发现根本没办法用,没有办法去Pass PHP页面地址
下面贴上Code大家帮忙看看哪里出问题了
<script type="text/javascript">
$('#cyclist-show button').on('show.bs.modal', function(e) {
$(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
$('.debug-url').html('Delete URL: <strong>' + $(this).find('#cyclist-show button').attr('href') + '</strong>');
});
</script>
$result = search_id($dbc, $id);
    if ($result != false && $result -> num_rows != 0) {
        echo "<div class = 'table-responsive'>";
        echo "<table class='table-responsive' id='cyclist-show' align='center'>";
            echo "<tr>
.... 省略
</tr>";
        while($row = mysqli_fetch_assoc($result)){
... 省略
echo "<td id='cyclist-button-td'>";
                                echo "<div class='hidden-xs'>";
                                ?>
                                <button class="btn btn-default" data-href="./delete-bicycle.php?id="<?php echo $row['ID'] ?>" data-toggle="modal" data-target="#confirm-delete">
                                Delete
                                </button>
                                <?php
                                echo "</div>";
                                echo "</td>";
....... // 省略
            }
            echo "</table>";
            echo "</div>";
        } else {
            echo "</br>You do not have any bicycle that registered with system";
        }
    ?>
</div>
</section>
<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">Delete Confirmation</h4>
            </div>
            <div class="modal-body">
                <p>You are about to delete this, this procedure is irreversible.</p>
                <p>Do you want to proceed?</p>
                <p class="debug-url"></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                <a class="btn btn-danger btn-ok">Delete</a>
            </div>
        </div>
    </div>
</div>
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.