In the store code in the apps, I know why you need the "weird hack" #96
AverseABFun
started this conversation in
General
Replies: 3 comments
-
Thank you
…On Thu, Nov 9, 2023, 9:57 AM Arthur Beck ***@***.***> wrote:
In the code
for (repo in repos) {
const repoItem = document.createElement('div')
repoItem.innerText = repo
repoItem.onclick = function() {
loadappListScreen(repoItem.innerText) // Weird hack to work around the fact that repo doesn't work but the innertext of the repoitem does
}
repoItem.className = "repoItem"
repoList.appendChild(repoItem)
}
The weird hack is necessary because you are looping through repos and
thus changing repo. However, repoItem is scoped inside the loop and thus
isn't changing. Therefore, you can get repoItem.innerText to get the
correct value. Also, the reason this is only an issue here, is because
repoItem.onclick is running after the loop has ended and thus repo has
been changed to final value in repos.
—
Reply to this email directly, view it on GitHub
<#96>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHKFT2MWXCKD7ILJKAA3HKLYDTVO3AVCNFSM6AAAAAA7EWOBU2VHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZVHAZTENZXGI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
This is smart. Thank you. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks!
…On Fri, Nov 10, 2023, 1:08 PM Madjik ***@***.***> wrote:
This is smart. Thank you.
—
Reply to this email directly, view it on GitHub
<#96 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATOOUFWXWTUSTSVP4GRHCC3YDZ3TTAVCNFSM6AAAAAA7EWOBU2VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TKMZWG4ZTE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In the code
The weird hack is necessary because you are looping through
repos
and thus changingrepo
. However,repoItem
is scoped inside the loop and thus isn't changing. Therefore, you can getrepoItem.innerText
to get the correct value. Also, the reason this is only an issue here, is becauserepoItem.onclick
is running after the loop has ended and thusrepo
has been changed to final value inrepos
.Beta Was this translation helpful? Give feedback.
All reactions