Procházet zdrojové kódy

Add typing.js dependency to the custom input function

shiny-input
Garrick Aden-Buie před 6 roky
rodič
revize
0be8efb83b
2 změnil soubory, kde provedl 32 přidání a 1 odebrání
  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 Zobrazit soubor

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 Zobrazit soubor



</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.

Načítá se…
Zrušit
Uložit