I am trying to fetch more detailed data and show this info ad-hoc in the same window. On bigger screens. On smaller screens I want to hide the list and show detailed when double click.
To illustrate my goal, i have done a very simple write to innerHTML.
http://94.237.92.101:6060/newposts (screens above 1800px shows both list and card)
const selected = table.getElementsByClassName('selected')
table.onclick = sel;
function sel(row) {
if (selected[0]) selected[0].className = '';
row.target.parentNode.className = 'selected';
table.className = '';
add2card(row.target.parentNode.innerHTML)
}
function add2card(text){
document.getElementById("add2card").innerHTML = text;
}
I have found three ways to do this.
- Fetch data via AJAX ( do not know how to parse and format the json )
- Fetch the normal way and show in an iFrame
- Store all content in the list (some data hidden) and do basically as above.
In my imagination there is a way to get a Go html template to act as a innerHTML.
OR a way to parse json and deliver a html as a value to insert as a innerHTML.
OR something like this:
data := tpl.ExecuteTemplate(w, page, data)
Any clue how to avoid AJAX is welcome!