将引导工具提示添加到闪亮应用程序中的列标题 [英] Add bootstrap tooltip to column header in shiny app
本文介绍了将引导工具提示添加到闪亮应用程序中的列标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将工具提示添加到数据表的每个列标题中,但是失败了.有人可以教我如何使用jQuery.
I am trying to add tooltips to each column header of the data table, but failed. Could anybody teach me how to do this using jQuery.
谢谢
shinyApp(
ui = fluidPage(
fluidRow(
tags$head(
tags$script( src = "https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"),
tags$script( src = "http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js")
),
column(12, tableOutput('table')
)
)
),
server = function(input, output) {
output$table <- renderTable(iris)
}
)
# DataTables example
shinyApp(
ui = fluidPage(
fluidRow(
column(12,
dataTableOutput('table')
)
)
),
server = function(input, output) {
output$table <- renderDataTable(iris)
tags$head(tags$script("
$('table th').each( function(){ console.log( $(this).text());
$(this).attr('data-toggle', 'tooltip')
$(this).attr('title', 'example text')
$(this).tooltip();
);
"))
}
)
推荐答案
向initComplete添加js函数以解决问题
Add a js function to initComplete solve the problem
output$table <- renderDataTable(iris,
options = list(
pageLength = 5,
initComplete = I("function(settings, json) {alert('Done.');
$('th').each( function(){this.setAttribute( 'title', 'Hihihi' );});
$('th').tooltip();
}")
)
这篇关于将引导工具提示添加到闪亮应用程序中的列标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文