Go Template - Give JavaScript variable to go method like an argument

How I can give value of $row_id to .GetClients method like an argument?

$(document).on("click", ".row", function() {
	row_id = $(this).find(".row_id").text();
    {{.GetClients $row_id}}
});

What does not work in your example?

Javascript runs in the browser. Go templates are evaluated before the page is sent to the browser. So you can’t pass things to the template from Javascript.

2 Likes

template: index.js:5: undefined variable “$client_id”

Yep, see @calmh comment before. Also, take a look over this interesting article about using functions in Go templates.

1 Like

Thanks. Sorry for late answer. Forum freezing my account…

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.