Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callbacks/passing values from the DOM back into Rust? #29

Closed
sezna opened this issue Aug 26, 2019 · 2 comments
Closed

Callbacks/passing values from the DOM back into Rust? #29

sezna opened this issue Aug 26, 2019 · 2 comments

Comments

@sezna
Copy link

sezna commented Aug 26, 2019

I'm trying to implement a "callback" where as a user types, the content they have typed thus far is sent back to Rust for some processing (namely, autocomplete). I'm unclear on the syntax or in general how this would be accomplished given the tools exposed in horrorshow. So, my question is two parts:
a) Is this possible at all?
b) If yes to (a), what would that look like?

After I figure this out, I would like to write up examples/documentation and contribute them to the repository to help others out.

Thanks!

@Stebalien
Copy link
Owner

Horrorshow just spits out HTML, interacting with JavaScript and the DOM isn't really in scope.

Basically, you'd need to listen for input events (https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event) (or keydown events) in javascript, then call back into rust (how depends on what tools you're using and whether you're running rust on the client using WASM or on a server).

@sezna
Copy link
Author

sezna commented Aug 26, 2019

Thanks for the response -- I guess I was thinking of including some script tag in horrorshow which handled the callback, but that does seem out of scope in hindsight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants