Создание карты поверх недавно преобразованного списка узлов - PullRequest
0 голосов
/ 31 мая 2019

Я хотел бы знать, как отобразить недавно преобразованный список узлов и добавить щелчок, который вызывает this.selectTab

До сих пор я реализовал предыдущий код

class TabLink {
    constructor(tabElement) {
        // assign this.tabElement to the tabElement DOM reference
        this.tabElement = tabElement;

        // Get the `data-tab` value from this.tabElement and store it here
        this.tabData = document.querySelector(`.tabElement[data-tab='${element.dataset.tab}']`);

        // We need to find out if a user clicked 'all' cards or a specific category.  Follow the instructions below to accomplish this task:    

        // Check to see if this.tabData is equal to 'all'
        if (data === "all") {
            // If `all` is true, select all cards regardless of their data attribute values
            // this.cards = ;
            return document.querySelectorAll(".card");
        } else {
            // else if `all` is false, only select the cards with matching this.tabData values
            // this.cards = ;
            return document.querySelectorAll(`.card[data-tab = '${data}']`);
        }


        // Map over the newly converted NodeList we just created in our if statement above. Convert each this.cards element into a new instance of the TabCard class. Pass in a card object to the TabCard class. 
        // this.cards = Array.from(this.cards).map();

        // Add a click event that invokes this.selectTab
        // this.tabElement.addEventListener();
    }

последние две закомментированные области - это то, с чем мне нужна помощь, мне также нужно знать, нахожусь ли я на правильном пути с предыдущей работой.

...