kurtobando/simple-tags

Last deleted <li> do not get removed from the "data-simple-tags" attribute

Closed this issue · 4 comments

Hello @HymedGh,

Thank you for checking "simple-tags" repository, and letting me know this bug. Will check this out later today, and commit the solution.

Hello @HymedGh,

Reported bug has been fix in commit 82b0f0e28ccc8c87d8c4a1bb5188902c7153a83c . Thank you for the reported bug.

Hey @kurtobando ,

Thx for solving this quick the reported issue.
Can you please let us know where in your code, the fix was made ?
I looked through twice, but wasn't able to identify it :/

Thank u for sharing your code btw ! Your function helped me a lot to create this :

image

@HymedGh
You are welcome. Here are the changes i made.
https://github.com/kurtobando/simple-tags/commit/82b0f0e28ccc8c87d8c4a1bb5188902c7153a83c

I move the line 34 to 36 in
source/script/script.js

    function DOMRender() {
        // clear the entire <li> inside <ul>
        DOMList.innerHTML = ""

        // render each <li> to <ul>
        arrayOfList.forEach((currentValue, index) => {
            let li = document.createElement("li")
            li.innerHTML = `${currentValue} <a>&times;</a>`
            li.querySelector("a").addEventListener("click", function () {
                onDelete(index)
            })

            DOMList.appendChild(li)
            
        })

        setAttribute()
    }

I move the setAttribute() outside the forEach() loop.