From aaf2db8657dd2ae373cfd14bbc717fbdb2244ca3 Mon Sep 17 00:00:00 2001 From: Lan Hui <1348141770@qq.com> Date: Wed, 4 Sep 2024 15:15:03 +0800 Subject: [PATCH] Fix Bug 501. The key fix is the first line in funciton wordTemplate() from word_operation.js, i.e., using double quotes instead of single quotes. --- app/static/js/word_operation.js | 22 +++++++++++++--------- app/templates/userpage_get.html | 8 ++++---- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/static/js/word_operation.js b/app/static/js/word_operation.js index e669655..684d350 100644 --- a/app/static/js/word_operation.js +++ b/app/static/js/word_operation.js @@ -1,7 +1,9 @@ function familiar(theWord) { let username = $("#username").text(); - let word = $("#word_" + theWord).text(); - let freq = $("#freq_" + theWord).text(); + let word = document.getElementById(`word_${theWord}`).innerText; + let freq = document.getElementById(`freq_${theWord}`).innerText; + console.log(theWord); + console.log(word); $.ajax({ type:"GET", url:"/" + username + "/" + word + "/familiar", @@ -27,8 +29,10 @@ function familiar(theWord) { function unfamiliar(theWord) { let username = $("#username").text(); - let word = $("#word_" + theWord).text(); - let freq = $("#freq_" + theWord).text(); + let word = document.getElementById(`word_${theWord}`).innerText; + let freq = document.getElementById(`freq_${theWord}`).innerText; + console.log(theWord); + console.log(word); $.ajax({ type:"GET", url:"/" + username + "/" + word + "/unfamiliar", @@ -95,14 +99,14 @@ function parseWord(element) { */ function wordTemplate(word) { // 这个模板应当与 templates/userpage_get.html 中的
...
保持一致 - return `+ return `
${word.word} ( ${word.freq} ) - 熟悉 - 不熟悉 - 删除 - 朗读 + 熟悉 + 不熟悉 + 删除 + 朗读 笔记
`; diff --git a/app/templates/userpage_get.html b/app/templates/userpage_get.html index cb29ce8..d3bf8bf 100644 --- a/app/templates/userpage_get.html +++ b/app/templates/userpage_get.html @@ -179,10 +179,10 @@ {{ word }} ( {{ freq }} ) - 熟悉 - 不熟悉 - 删除 - 朗读 + 熟悉 + 不熟悉 + 删除 + 朗读 笔记 -- 2.17.1