Action button in index.html/server.R implementation

Hi all,

I am having some trouble with the shiny index.html/server.R implementation of the action button (rather than the usual ui.R/server.R implementation).

Namely, I can't seem to get an action button to work in my html code. Here is what I have so far:
From here, I modified it like so


<button class="btn action-button" type='button' onclick="buttonClicked()" id="submit">Start</button>
    function submitButton() {
        Shiny.onInputChange("submit_loc", Math.random());


server <- function(input, output) {
                 cat('input detected')

From what I understand, this would mean that observeEvent would see that submit_loc value changes, which would then trigger it. However this does not seem to work either, and I am not sure why. This is my first time using Shiny, and R in general, so I am not sure if I am missing something obvious. I found that most examples/questions are based around people using ui.R and not index.html, which is what I think is throwing me off, as in ui.R it seems all you need to do is

actionButton(inputId = "submit_loc",label = h4("START")

If there is a 'proper' way of implementing this, please let me know. (or if there is an html alternative to actionbutton in ui.R)


Shouldn't these be the same function instead of two different functions ?

Oops, sorry. That was a typo when I was typing the code into the textbox. However, I figured it out, I wasn't properly importing all the shinyjs scripts. Thank you for the reply though.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.