made the current category button disabled
All checks were successful
Web/pipeline/head This commit looks good
All checks were successful
Web/pipeline/head This commit looks good
This commit is contained in:
parent
cbe4a615df
commit
71c5f58d30
1 changed files with 4 additions and 4 deletions
|
@ -22,10 +22,10 @@ function populateBlog(json, cat) {
|
|||
list.html("");
|
||||
cats.html("");
|
||||
|
||||
addCatButton(json, cats, "All");
|
||||
addCatButton(json, cats, "All", cat);
|
||||
for (let i = json.length - 1; i >= 0; i--) {
|
||||
let obj = json[i];
|
||||
addCatButton(json, cats, obj.cat);
|
||||
addCatButton(json, cats, obj.cat, cat);
|
||||
if (cat === "All" || obj.cat === cat) {
|
||||
let p = /*html*/ `
|
||||
<div class="card bg-light blog-entry rounded-0">
|
||||
|
@ -49,10 +49,10 @@ function populateBlog(json, cat) {
|
|||
archive.html(`<em>There are no archived ${cat} posts.</em>`);
|
||||
}
|
||||
|
||||
function addCatButton(json, cats, cat) {
|
||||
function addCatButton(json, cats, cat, currCat) {
|
||||
let catAnchor = `blog-cat-${cat.toLowerCase().replace(" ", "_")}`;
|
||||
if (!$(`#${catAnchor}`).length) {
|
||||
cats.append( /*html*/ `<button type="button" class="btn btn-link blog-cat-button" id=${catAnchor}>${cat}</button>`);
|
||||
cats.append( /*html*/ `<button type="button" class="btn btn-link blog-cat-button" id=${catAnchor} ${cat === currCat ? "disabled" : ""}>${cat}</button>`);
|
||||
$(`#${catAnchor}`).on('click', function () {
|
||||
populateBlog(json, cat);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue