Skip to content

Navigating programatically in new window/tab? #2476

Closed Answered by ydirson
ydirson asked this question in Q&A
Discussion options

You must be logged in to vote

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:

fn open_in_new_tab_and(url: &str, action: impl FnOnce() -> ()) {
    window().open_with_url_and_target(url, "_blank")
        .expect("should open a window");
    action();
}

...
                        <leptonic::Button on_click=move |_|
                            open_in_new_tab_and(&af_url, || show_when.set(false))
                        >

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@ydirson
Comment options

Answer selected by ydirson
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2460 on March 31, 2024 16:55.