Rocket: call the rust function from handlebars templates

Created on 20 Aug 2018  路  4Comments  路  Source: SergioBenitez/Rocket

Hi,
rocket version:

rocket = "0.3.15"
rocket_codegen = "0.3.15"
[dependencies.rocket_contrib]
default-features = false
features = ["handlebars_templates", "json"]

I have a button on a page:
<button>generate!</button>
The logic for this button is the following:
When a user clicks on a button, a method is called from the Rust code. This method returns a struct that is displayed on the same page in the <p> </p> field. I have a question: how do I process an onclick event to accomplish the intended. If there are examples somewhere, I will be glad if you share the link. I could not find.

question

All 4 comments

Hi, you could use Ajax for that, e.g. using the fetch API (with JavaScript)

Hi, jens1o.
Your idea is: the handlebars calls some hidden URL in my application via JS script. on that URL, as a response, I will send the struct. And next, I display that struct via Ajax. Correct?

Hi, jens1o.
That work! Thanks!

Great! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Perseus101 picture Perseus101  路  4Comments

marceloboeira picture marceloboeira  路  3Comments

sphinxc0re picture sphinxc0re  路  3Comments

paulvt picture paulvt  路  4Comments

incker picture incker  路  3Comments