## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval = FALSE ) ## ----------------------------------------------------------------------------- # install.packages("htmxr") # # # development version # pak::pak("hyperverse-r/htmxr") ## ----------------------------------------------------------------------------- # library(htmxr) # hx_run_example("hello") ## ----------------------------------------------------------------------------- # hx_slider_input( # id = "bins", # label = "Number of bins:", # value = 30, # min = 1, # max = 50, # get = "/plot", # send GET /plot on trigger # trigger = "input changed delay:300ms", # trigger: input event, debounced 300ms # target = "#plot" # replace the content of #plot # ) ## ----------------------------------------------------------------------------- # tags$div(id = "plot") |> # hx_set( # get = "/plot", # trigger = "load", # fires once when the element is loaded # target = "#plot", # swap = "innerHTML" # ) ## ----------------------------------------------------------------------------- # #* @get /plot # #* @query bins:integer(30) # #* @parser none # #* @serializer none # function(query) { # generate_plot(query$bins) # } ## ----------------------------------------------------------------------------- # # Minimal api.R structure # library(htmxr) # # #* @get / # #* @serializer html # function() { # hx_page( # hx_head( # title = "My app" # ), # tags$div( # id = "content" # ) |> # hx_set( # get = "/content", # trigger = "load", # target = "#content" # ) # ) # } # # #* @get /content # #* @serializer html # function() { # tags$p("Hello from the server!") # } ## ----------------------------------------------------------------------------- # # List all available examples # hx_run_example() # # # Dynamic table filtering with hx_select_input() # hx_run_example("select-input")