make texts into a tags
This commit is contained in:
parent
7ee4bac3fa
commit
3689945cfe
1 changed files with 10 additions and 2 deletions
|
|
@ -5,7 +5,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
async function loadTexts() {
|
||||
const res = await fetch('/api/texts');
|
||||
const texts = await res.json();
|
||||
textsList.innerHTML = texts.map(text => '<li>' + text.name + '</li>').join('');
|
||||
textsList.innerHTML = texts.map(text =>
|
||||
'<li><a href=/admin/texts/'
|
||||
+ text.id
|
||||
+ '>'
|
||||
+ text.name
|
||||
+ '</a></li>').join('');
|
||||
}
|
||||
|
||||
form.addEventListener('submit', async (e) => {
|
||||
|
|
@ -18,7 +23,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
if (res.ok) {
|
||||
const text = await res.json();
|
||||
const li = document.createElement('li');
|
||||
li.textContent = text.name;
|
||||
const a = document.createElement('a');
|
||||
a.href = '/admin/texts/' + text.id;
|
||||
a.textContent = text.name;
|
||||
li.appendChild(a);
|
||||
textsList.appendChild(li);
|
||||
form.reset();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue