Search code examples
javascriptjqueryhtmljquery-bootgrid

Code works on stack snippet different to a single html file


I have some code and it works fine on stack snippet.

But when i insert it on my server or just in .html file, the refresh button become smaller!

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>
There is COPY and PASTE of the code, no differents! Is there some snippet feathers make it work, and how can i make it work on my server? More info on my previous question.


Solution

  • Make sure you specify a doctype when moving the code into its own html file. Stack Snippets and JS Fiddle automatically add the HTML5 doctype <!DOCTYPE html> to their output (although this is configurable in the case of JS Fiddle). Not supplying a doctype can lead to odd results as the browser wont know what rendering mode to use.

    Taken from 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.