title: How to skip elements in chaining modal approach (shinyalert library)?
body: <p>My problem with breaking a loop insidse <strong>shinyalert</strong> has been solved <a href="https://stackoverflow.com/questions/71897692/how-to-break-a-for-loop-basing-on-captured-shinyalert-input-value/71924191#71924191">in this post</a>.</p>
  <p>I decided to try <strong>&quot;Chaining modals&quot;</strong> approach.</p>
  <p>The approach seems to work in my case,  hovewer I am facing another problem-
  as I am not using any loop, values are not used as a parameter anymore (vector &quot;all.elements&quot; is not being used).<br />
  In my case it is a little bit a problem, because in my original app &quot;elements&quot; to be checked are being selected beforewards and only a part of vector elements should be included in &quot;shinyalert&quot; part.<br />
  For this reason I would like to keep &quot;vector of elements&quot; with elements selected beforewards. Elements not included in the vector should be skipped in the chain of modals (in the example element &quot;C&quot; should be skipped, that means &quot;Do you accept element C?&quot; message should not pop up even if elements &quot;A&quot; and &quot;B&quot; had been previously confirmed by a user).<br />
  App should proceed from &quot;Do you accept element B?&quot; to &quot;Do you accept element D?&quot; question directly<br />
  I was trying to achieve that using <strong>ifelse</strong> function inside my shinyalert but I have not succeeded.</p>
  <p>Is there way to do that? Below the code I wrote using &quot;Chaining modals&quot; approach.</p>
  <pre><code>library(shiny)
  library(shinyalert)
  
  ui &lt;- fluidPage(
      actionButton(&quot;run&quot;, &quot;Run&quot;)
  )
  
  server &lt;- function(input, output, session) {
  
  observeEvent(input$run, {
      
      all.elements &lt;- c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;, &quot;E&quot;)
      selected.elements &lt;- c(&quot;A&quot;, &quot;B&quot;, &quot;D&quot;, &quot;E&quot;)
      
      shinyalert(
          title = &quot;Do you accept element A?&quot;,
          showCancelButton =  TRUE,
          callbackR = function(value) {
              ifelse(value == TRUE,
                     shinyalert(title = &quot;Do you accept element B?&quot;,
                                showCancelButton =  TRUE,
                                callbackR = function(value) {
                                    ifelse(value == TRUE, shinyalert(title = &quot;Do you accept element C?&quot;,
                                                                     showCancelButton =  TRUE,
                                                                     callbackR = function(value) {
                                                                         ifelse(value == TRUE, shinyalert(title = &quot;Do you accept element D?&quot;,
                                               showCancelButton =  TRUE, callbackR = function(value) {
                                                   ifelse(value == TRUE,
                                                          shinyalert(title = &quot;Do you accept element E?&quot;,
                                                                     showCancelButton =  TRUE), decision &lt;&lt;- &quot;STOP&quot;)}), decision &lt;&lt;- &quot;STOP&quot;)}), decision &lt;&lt;- &quot;STOP&quot;)}), decision &lt;&lt;- &quot;STOP&quot;)}
      )
  })
  }
  
  shinyApp(ui = ui, server = server)
  </code></pre>
  <p>Another thing I noticed, when I click &quot;OK&quot; quickly, sometimes the consecutive message does not appear.
  Maybe there is a way to do similar thing using <strong>Modals approach built in Shiny</strong>, without using the shinyalert library?</p>