Edit: Trying to make bindings to JS from R via Shiny, looking for direction on where documentation for function/methods is.
Shiny repex here. I am looking at console.
app_ui <- function(request) {
tagList(
# Leave this function for adding external resources
tags$head(
tags$script(
" var DT_table = new Shiny.InputBinding();
$.extend(DT_table, {
find: function(scope) {
// JS logic $(scope).find('whatever')
console.log($('#table1'))
var table = $('#table1').data();
console.log(table)
},
getValue: function(el) {
// JS code to get value
},
setValue: function(el, value) {
// JS code to set value
},
receiveMessage: function(el, data) {
// this.setValue(el, data);
},
subscribe: function(el, callback) {
$(el).on('click.DT_table', function(e) {
callback();
});
},
unsubscribe: function(el) {
$(el).off('.DT_table');
}
});
Shiny.inputBindings.register(DT_table, 'shiny.whatever');
"
)
),
# Your application UI logic
fluidPage(
h1("DT.V2"),
shiny::verbatimTextOutput("colnames"),
br(),
DT::DTOutput("table1")
)
)
}
app_server <- function(input, output, session) {
# Your application server logic
data("iris")
output[["table1"]] <-
DT::renderDT({
DT::datatable(
iris
)
})
}
shinyApp(app_ui, app_server)
I am trying to build some custom bindings between Shiny and Javascript and am at a bit of a loss as to where to find documentation on the JavaScript methods (if thats even the right term?). FYI in Reprex I am using the golem input binding wireframe.
In the Reprex I have printed the object of 'table1' to the console, easy. After that, however, I only found the 'data' method with a lot of inspecting trial and error.
Looking here would be the sensible first place, but for example $('#table1').DataTable();
returns an error ('Uncaught TypeError: $(...).DataTable is not a function').
Where can I find which methods I can use? Eventually I would like to get all the index's or values of a column on a given event.