Callback page redirect

MiServer is Dyalog's APL-based web development framework

Callback page redirect

Postby Davin Church on Sat Dec 17, 2022 3:32 am

Pardon my newbie question, but I want an APL callback fn to redirect their browser to a new page, just like it was an <a> link that was clicked on. However it needs to be done under program control because the URL is being dynamically generated.

Is there a built-in way to do this?
Davin
Davin Church
 
Posts: 2
Joined: Sun Jul 25, 2021 2:56 am

Re: Callback page redirect

Postby Brian|Dyalog on Sat Dec 17, 2022 1:30 pm

Hi Davin,

To redirect to a page from a callback function, just return some JavaScript to set location.href to the new URL.

Code: Select all
 :Class index : MiPage                               
                                                     
     ∇ Compose                                       
       :Access public                               
       (Add _.Button'Click Me').On'click' 'callback'
     ∇                                               
                                                     
     ∇ r←callback                                   
       :Access public                               
       r←Execute'location.href="https://dyalog.com"'
     ∇                                               
                                                     
 :EndClass                                           


I hope this helps!
/Brian
User avatar
Brian|Dyalog
 
Posts: 114
Joined: Thu Nov 26, 2009 4:02 pm
Location: West Henrietta, NY

Re: Callback page redirect

Postby Davin Church on Sat Dec 17, 2022 2:00 pm

Excellent! Thanks, Brian. My JS is very weak and wasn't even sure how to approach that.
Davin
Davin Church
 
Posts: 2
Joined: Sun Jul 25, 2021 2:56 am


Return to MiServer

Who is online

Users browsing this forum: No registered users and 0 guests