Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DataTable to fix bug with search input #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions _posts/atoms/2018-08-30-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
description: A `%div` container with the CSS class `.table-responsive` makes the table responsive. The width of columns can be adjusted by using the
[Bootstrap's sizing classes](https://getbootstrap.com/docs/4.1/utilities/sizing/) on the `%th` tags
([Bootstrap's grid system](https://getbootstrap.com/docs/4.1/layout/grid/) doesn't work for tables in Chrome).
Additionally, we are using [DataTable](https://datatables.net/examples/styling/bootstrap4)'s [responsive](https://datatables.net/extensions/responsive/)
and style them with striped rows (`.table-striped`) and borders (`.table-bordered`). However, you can use tables with and without datatables.
Additionally, you can also use [DataTable](https://datatables.net/examples/styling/bootstrap4)'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence seems out of place now. Do we still need it? I don't believe so.

Style it with striped rows (`.table-striped`) and borders (`.table-bordered`).
Do not forget to initialize it with `initializeDataTable()` and to wrap it inside the class `.obs-dataTable`,
as this is solving a [bug related to the search field not being resposive](https://github.com/mkhairi/jquery-datatables/issues/14).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo here: not being responsive

---

%h5 Table
Expand Down Expand Up @@ -34,27 +36,26 @@

%h5 Table with DataTable

%table.responsive.table.table-striped.table-bordered#my-datatable
%thead
%tr
%th Fruits
%th Origin
%th Vendor
%tbody
%tr
%td Oranges
%td Bananas
%td Kiwis
%tr
%td Spain
%td Brazil
%td Germany
%tr
%td Fruits Are Us
%td Fruits & Vegetables Inc.
%td SUSE Fruit Company Ltd.
.obs-dataTable
Ana06 marked this conversation as resolved.
Show resolved Hide resolved
%table.table.table-striped.table-bordered#my-datatable
%thead
%tr
%th Fruits
%th Origin
%th Vendor
%tbody
%tr
%td Oranges
%td Bananas
%td Kiwis
%tr
%td Spain
%td Brazil
%td Germany
%tr
%td Fruits Are Us
%td Fruits & Vegetables Inc.
%td SUSE Fruit Company Ltd.

:javascript
$('#my-datatable').DataTable({
responsive: true
});
= content_for :ready_function do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should still be :javascript as content_for doesn't work in Jekyll

initializeDataTable('#my-datatable');