0

I have a EJS template that's used to display several steps:

  1. Display a button, that starts a process on the node.js backend
  2. Display information what's happening. This step has a duration of 10s.
  3. Display a textinput and button

Transitioning from step 1 to step 2 is easy: The button triggers a post request that returns the updated view with the new step-value. I'm struggeling with the timed transition from step 2 to step 3. I either

  1. Need to update the HTML output to the client from the server
  2. Implement a setTimeout(); in the EJS template.

Second option is maybe easier, but I'm not able to get something like

<% if (step == 2) { %>
    <p>Step 2 is happening right now</p>
    <%
    setTimeout(function() {
        step = step + 2;
    }, 1000 )
    %>
<% } %>

to work. This approach is not working for me, since the 10s start after the button from step 1 pressed.

Thanks in advance!

Community
  • 1
  • 1
Boern
  • 7,233
  • 5
  • 55
  • 86
  • 1
    the setTimeout call within the context of an EJS template is not going to work. That code is executed on the server so when it DOES execute, if at all frankly, the HTML would've already been sent to the client. – Joey Guerra Dec 12 '15 at 18:47
  • Thanks Joey, I ended up with `` to trigger a new reload without POST data – Boern Dec 13 '15 at 10:34

0 Answers0