javascript - 为什么 Bootstrap 的 Dropdown Toggle 在某些环境下有效而在其他环境下无效?

标签 javascript jquery css twitter-bootstrap bootstrap-table

我非常困惑为什么我的 Bootstrap 表格底部的页面大小下拉菜单(“每页显示 10 条记录”)在某些环境中有效,但在其他环境中无效。我想创建一个 Bootstrap Table分页功能就像this .当我通过 Sublime Text 或 Brackets(Adobe 的文本编辑器)预览代码时,下拉菜单不起作用。当我将代码插入到 my Squarespace blog 时在页面底部,它也不起作用。但是,当我将代码插入到 JSFiddle 时或者我的 Webflow site , 有效。什么可能导致冲突?我是编程新手,如果您能给我一些解决问题的提示,我将不胜感激!

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/bootstrap-table.min.css">

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<table data-toggle = "table" data-pagination = "true" data-pagination = "true" data-page-list="[10, 20, 50, 100, 200]">
    <thead>
        <tr>
            <th data-sortable="true">Symbol</th>
            <th data-sortable="true">Company Name</th>
            <th data-sortable="true">EV/EBITDA</th>
            <th data-sortable="true">Trailing P/E</th>
            <th data-sortable="true">Forward Dividend Yield</th>
            <th data-sortable="true">Payout Ratio</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>FLWS</td>
            <td>1-800 FLOWERS.COM, Inc.</td>
            <td>9.18</td>
            <td>28.33</td>
            <td>N/A</td>
            <td>N/A</td>
        </tr>
        ...
    </tbody>
</table>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>

<!-- Latest compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/bootstrap-table.min.js"></script>

最佳答案

jQuery 需要在 Bootstrap 的 JS 文件之前加载:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

<!-- Latest compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/bootstrap-table.min.js"></script>

它适用于 jsFiddle,因为它们生成正确排序库的标记。如果您在 Stack Snippet 中以相同顺序加载您的库,您会在此站点上看到相同的行为。

值得注意的是,这是在 Bootstrap's site 上明确调用的:

Also note that all plugins depend on jQuery (this means jQuery must be included before the plugin files).

关于javascript - 为什么 Bootstrap 的 Dropdown Toggle 在某些环境下有效而在其他环境下无效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32545944/

相关文章:

jquery - 我可以有两个处理程序的 url 吗?

jquery - 如何为打开的模式窗口设置新的滚动条(包括 jsfiddle)?

javascript - Bootstrap 4 Modal 不适用于 Angular 2

javascript - 如何检查2个正则表达式是否相同会计语法差异?

javascript - 影响 JavaScript/CSS 的 HTML 空间格式

javascript - 正确的 jQuery 来替换 <span> 元素中的内容

html - 带有垂直文本和文本溢出的表格

javascript - 使用 JavaScript/jQuery 滚动到 DIV 的顶部?

javascript - 根据表单中的单选按钮(是/否)响应动态启用检查列表

javascript - 替换 CodeMirror token ?