Giter Club home page Giter Club logo

Comments (2)

frasemcl avatar frasemcl commented on June 16, 2024

Update on this, I got it working well enough by using an if statement at the start of my observe block, but I could still use some help if anyone has suggestions. Since input$conditional_input1,2and3 only exists if user answers 'Yes' to a previous input, the following works pretty well, but I'm sure there is a more elegant way to achieve this:

    observe({
      # Thought that req() would work but ended up working better with subsequent if statement
      # req(input$conditional_input1)
      if (!isTruthy(input$conditional_input1) && !isTruthy(input$conditional_input2) && !isTruthy(input$conditional_input3)) {
      print('conditionally running')
      lapply(c("conditional_input1", "conditional_input2", "conditional_input3", function(n) {
        observe({
          validateF7Input(
            inputId = ns(n),
            pattern = "^\\d*\\.?\\d+$", # regex for int or float
            error = "Please enter a number"
          )
        })
      }
      )
      }
    })

Apologies that this example or the examples above aren't given in a demo shiny app.

from shinymobile.

frasemcl avatar frasemcl commented on June 16, 2024

Thx for your consideration. FYI for my use case I ended up going with your radio input combined with shinyjs show() and hide() and that seems to be working well so far. I decided the falsy check above and the observe() within observe() was too hard to reason about and the input warnings weren't working perfectly.

from shinymobile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.