I have not done much with golang on the web, so take this with a grain of 
salt.

You are right in judging why it does not work - by the time the Javascript 
runs, the template generation is long over with.

That said, I think you have two basic options:

Option 1: Front-load the data into Javascript

That is, the template needs to write ALL the data necessary for the 
sub-region into Javascript (i.e. have the Template produce a bit of JSON 
assigned to a variable in the script region), then have more Javascript 
that uses that data to render the sub-region on the fly on the basis of the 
selection.

Option 2: Use AJAX to pull a smaller template from your Go server, passing 
in the parameter gathered from Javascript, and replacing the sub-region in 
the DOM. So basically, you'd have more Javascript in the first template, 
and the sub-region would get pulled out into a second template on the Go 
side.

https://stackoverflow.com/questions/41136000/creating-load-more-button-in-golang-with-templates
https://stackoverflow.com/questions/36251743/render-a-partial-template-with-passed-parameters

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to