-
broader contextI'm trying to build components (missing from Leponic today) for transient UI elements (popup dialogs and dropdown menus) containing user triggers to:
I've experimented with Leptonic's my problemWe have 2 ways to navigate, each apparently with their own limitations:
possible solutionMaybe alternatives consideredThe only alternative I could think about is separating the navigation aspect (which can then be a link with |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I encourage you to look at the pub fn navigate_to(path: &str) {
logging::log!("navigating to: {}", path);
let result = web_sys::window()
.expect("Failed to get window")
.location()
.set_href(path);
if let Err(e) = result {
logging::error!("failed to navigate: {:?}", e);
}
}
pub fn reload() {
let result = web_sys::window()
.expect("Failed to get window")
.location()
.reload();
if let Err(e) = result {
logging::error!("failed to reload: {:?}", e);
}
} I'm sure you can find an API to imperatively open a new tab, I just don't remember the correct API to use. If you can do it with JS, you can do it with |
Beta Was this translation helpful? Give feedback.
-
I agree with @johnbchron that the correct approach here is just going to be to use the Web platform's built-in ways to do this via web-sys. I do not know how to do this off the top of my head, but figuring out how you'd do it with JavaScript and then translating that into web-sys calls would be the right approach. |
Beta Was this translation helpful? Give feedback.
Thanks for the hint, the web-sys API is
Window.open_with_url_and_target()
So things can then go as follows to close the modal containing a button at the same time as following the link: