I am trying to write a javascript function to extend the R shiny action button demo. I would like the user to be able to enter a number by both clicking the action button an
Add below code in shiny app.
Outside Ui and Server function -
jscode <- '
$(function() {
var $els = $("[data-proxy-click]");
$.each(
$els,
function(idx, el) {
var $el = $(el);
var $proxy = $("#" + $el.data("proxyClick"));
$el.keydown(function (e) {
if (e.keyCode == 13) {
$proxy.click();
}
});
}
);
});
'
inside Ui function-
tags$head(tags$script(HTML(jscode))),
`data-proxy-click` = "goButton"
goButton - name of actionbutton
This will work 100% enjoy.