【问题标题】:"popover" problems on twitter bootstrap css/javascript librarytwitter bootstrap css/javascript 库上的“popover”问题
【发布时间】:2011-11-26 22:46:06
【问题描述】:

我尝试使用 twitter bootstrap 在我的网站上实现 popover javascript,但我做不到。如果有人可以帮助我编写代码,我将不胜感激。在此先感谢您。

<head>
...
    <script src="scripts/jquery.min.js"></script>
    <script src="scripts/html5.js"></script>  
    <script src="scripts/bootstrap-tabs.js"></script>
    <script src="scripts/bootstrap-alerts.js"></script>
    <script src="scripts/bootstrap-popover.js"></script>
    <script src="scripts/bootstrap-twipsy.js"></script>
    <script src="scripts/bootstrap-modal.js"></script>
    <script src="1.3.0/bootstrap-scrollspy.js"></script> -->

    <link rel="stylesheet" href="bootstrap.css" />

...
</head>
<body>
...

                                <div class="tab-content">
                                    <div class="active" id="dwcenter_iso">
                                        <table class="zebra-striped">
                                            <thead>
                                                <tr>
                                                    <th>Arquivo</th>
                                                    <th>Tamanho</th>
                                                    <th>Data</th>
                                                    <th>md5</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <tr>
                                                    <td><a href="download.php">nimbus-opensource-backup-1.1.iso</a> <span class="label success">new</span></td>
                                                    <td>332M</td>
                                                    <td>16/09/11</td>

<!-- HERE GOES -->
                                                 <td><a href="#" class="btn danger" rel="popover" title="md5 Check Sum" data-content="343453453453453rfef34">ver</a>
                                                       <script>
                                                                $(function () {
                                                          $('a[rel=popover]')
                                                            .popover({
                                                              html: true
                                                            })
                                                            .click(function(e) {
                                                              e.preventDefault()
                                                            })
                                                        })
                                                      </script> 
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>nimbus-opensource-backup-1.0.iso <span class="label important">deprecated</span></td>
                                                    <td>332M</td>
                                                    <td>10/08/11</td>
                                                    <td>ver</td>
                                                </tr>
                                                <tr>
                                                    <td>nimbus-opensource-backup-0.9beta.iso <span class="label important">deprecated</span></td>
                                                    <td>380MB</td>
                                                    <td>25/09/10</td>
                                                    <td>ver</td>
                                                </tr>

                                            </tbody>
                                        </table>
                                    </div>


...
</body>

我已经尝试过“html: true”和引导文档示例“offset: 10”。 它确实显示了红色的危险按钮,但没有任何反应(弹出框不起作用)。

还有别的,我怎么能在表格的 TD 元素而不是按钮上实现呢?

【问题讨论】:

    标签: javascript css twitter-bootstrap


    【解决方案1】:

    更改这两个脚本,因为 popover 是 twipsy 的扩展,需要先加载...

    <script src="scripts/bootstrap-twipsy.js"></script>
    <script src="scripts/bootstrap-popover.js"></script>
    

    您不需要将 html 设置为 true,这是我的选项,您可以根据需要更改

    $(function(){
       $(".btn").popover({
           offset: 5,
           placement: 'left'
        });
    });
    

    【讨论】:

    • 这很顺利。但是 offset 属性到底有什么作用呢?
    • @Pabluez 你可以在这里看到弹出框的所有选项:twitter.github.com/bootstrap/javascript.html#popover
    • 现在,您需要包含“tooltip.js”而不是“twipsy.js”。
    • 它没有提到offset属性在popovers中代表什么......谁能告诉它的用途?
    • 偏移属性用于将弹出框“x”像素量推离点击目标,尽管文档已从 v2 中删除,因此不确定它是否仍然有效。
    猜你喜欢
    • 2011-11-24
    • 2012-02-10
    • 2013-08-06
    • 1970-01-01
    • 1970-01-01
    • 2014-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多