javascript - 代码适用于不同于单个 html 文件的堆栈片段

标签 javascript jquery html jquery-bootgrid

我有一些代码,它在堆栈片段上运行良好。

但是当我将它插入我的服务器或只是插入 .html 文件时,刷新按钮变小了!

enter image description here

<link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/css/bootstrap.css" rel="stylesheet"/>
<link href="http://cdnjs.cloudflare.com/ajax/libs/jquery-bootgrid/1.1.4/jquery.bootgrid.css" rel="stylesheet"/>

<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/js/bootstrap.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-bootgrid/1.1.4/jquery.bootgrid.js"></script>


<script>
 $(function () {
      var testGrid = $("#testGrid").bootgrid({
        navigation: 3,
        ajax: true,
        url: "controllers/getListFiles",
        post: function () {
          return {
            type: 'req',
            expanded: $('#exp').text()
          };
        },
        responseHandler: function (response)
        {
          return response.data;
        }
      });
    });
</script>



    <div id="autoOut" class="tab-pane fade in active">
      <span id="exp" style="display: none;"></span>
      <h3>Auto OUT</h3>
      <table id="testGrid" class="table table-condensed table-hover table-striped">
        <thead>
          <tr>
            <th data-column-id="date" class="col-md-3">Дата/Время</th>
            <th data-column-id="expander" data-formatter="expander" class="col-md-1">Список</th>
            <th data-column-id="file" class="col-md-4">Имя файла</th>
            <th data-column-id="uid" class="col-md-4">UID</th>
            <th data-column-id="accReqId" class="col-md-2">AccountsRequestId</th>
          </tr>
        </thead>
      </table>
    </div>
有代码的复制和粘贴,没有区别!是否有一些片段羽毛可以让它工作,我怎样才能让它在我的服务器上工作? 关于我之前的更多信息 question .

最佳答案

确保在将代码移动到它自己的 html 文件中时指定文档类型。 Stack Snippets 和 JS Fiddle 自动添加 HTML5 文档类型 <!DOCTYPE html>到他们的输出(尽管这在 JS Fiddle 的情况下是可配置的)。不提供文档类型会导致奇怪的结果,因为浏览器不知道要使用哪种呈现模式。

取自http://www.w3.org/QA/Tips/Doctype :

But the most important thing is that with most families of browsers, a doctype declaration will make a lot of guessing unnecessary, and will thus trigger a "standard" rendering mode.

关于javascript - 代码适用于不同于单个 html 文件的堆栈片段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30126886/

相关文章:

javascript - 选中复选框后执行两次函数

html - 当位置相对导航链接未悬停时,绝对定位的大型菜单消失

javascript - 仅向模型所有者广播消息

javascript - es6 模块到 commonjs,在 node harmony 标志下使用 typescript

javascript - javascript异步加载与jquery ajax(或getscript)异步加载的优缺点

html - 如果必须相对定位,如何构建图像网格

javascript - 引用错误 : AudioContext not defined

javascript - 如何在 FireFox 中检查 Javascript 中的无效日期

php - 一键插入数据库并为该数据调用 AJAX

javascript - Jquery点击打开模态返回 "undefined is not a function"