forked from PnX-SI/GeoNature-atlas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add dataTable plugin to manage articles
Use dataTable to get features of search , order table of artciles in details species Reviewed-by: andriacap
- Loading branch information
Showing
2 changed files
with
73 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
$(document).ready(function() { | ||
const table = $("#table_articles").DataTable({ | ||
"paging": true, | ||
"ordering": true, | ||
"info": true, | ||
"language": { | ||
url: '//cdn.datatables.net/plug-ins/2.0.2/i18n/fr-FR.json', | ||
}, | ||
"columnDefs": [ | ||
{ "orderable": false, "targets": [0, 3] } | ||
] | ||
}); | ||
|
||
$("#table_articles").on("click", "tr", function () { | ||
const row = table.row(this); | ||
const iconElement = $(this).find('.btn-more'); | ||
console.log(iconElement) | ||
if (row.child.isShown()) { | ||
row.child.hide(); | ||
$(this).removeClass("shown"); | ||
iconElement.removeClass("fa-chevron-down").addClass("fa-chevron-right"); | ||
} else { | ||
const articleIndex = row.index(); | ||
const article = articles[articleIndex]; | ||
|
||
row.child( | ||
"<div class='moreInfo'>" + | ||
"<strong>Description:</strong>" + | ||
`${article.description}` + "<br>" + | ||
"<strong>Date:</strong> " + `${article.date}` + | ||
"</div>" | ||
).show(); | ||
$(this).addClass("shown"); | ||
iconElement.removeClass("fa-chevron-right").addClass("fa-chevron-down") | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters