Quellcode durchsuchen

Add typing.js dependency to the custom input function

shiny-input
Garrick Aden-Buie vor 6 Jahren
Ursprung
Commit
0be8efb83b
2 geänderte Dateien mit 32 neuen und 1 gelöschten Zeilen
  1. +8
    -1
      inst/shiny-input-app/app.R
  2. +24
    -0
      inst/shiny-input-app/dev-shiny-input.Rmd

+ 8
- 1
inst/shiny-input-app/app.R Datei anzeigen

div( div(
class = "form-group typing-speed", class = "form-group typing-speed",
label(class = "control-label", `for` = inputId, .label), label(class = "control-label", `for` = inputId, .label),
textarea(id = inputId, class = "form-control", placeholder = placeholder)
textarea(id = inputId, class = "form-control", placeholder = placeholder),
htmltools::htmlDependency(
name = "typingSpeed",
version = "0.0.1",
src = ".",
script = "typing.js",
all_files = FALSE
)
) )
) )
} }

+ 24
- 0
inst/shiny-input-app/dev-shiny-input.Rmd Datei anzeigen



</details> </details>


`r github_sha_link("6fffc2337ad475af2ab09ee571014afdbb680fb6")`

If you use the snippet, If you use the snippet,
it automatically walks you through it automatically walks you through
the first pass of parts that need to be changed. the first pass of parts that need to be changed.
another package that impelements an in put with the same `bindingName`. another package that impelements an in put with the same `bindingName`.
Here we use `js4shiny`. Here we use `js4shiny`.

## Add a dependency to the typing input

To have `typing.js` included with our input,
we use `htmltools::htmlDependency()` inside our input function.
This guarantees that `typing.js` is loaded once per page
and is included whenever a `typingSpeedInput()` is created.

```{r}
# I used the htmldeps snippet for this
htmltools::htmlDependency(
name = "typingSpeed",
version = "0.0.1",
src = ".",
script = "typing.js",
all_files = FALSE
)
```

Now when you run the app,
you'll see `"FIXME"` as the output of `input$typing`.
That's our next step.

Laden…
Abbrechen
Speichern