我想在我闪亮的应用程序中包含一个语义形状元素(形状:
https://semantic-ui.com/modules/shape.html#/usage)。
我可以使用shinyjs
和shiny.semantic
构建形状。
但我不知道如何通过点击它来创建一个翻转形状的按钮。
这是一个例子:
Ui.R:
library(shiny)
# Define UI for application that draws a histogram
shinyUI(semanticPage(
shinyjs::useShinyjs(),
div(class="ui text shape",
div(class="sides",
div(class="ui header side active","This side starts visible."),
div(class="ui header side","This is yet another side"),
div(class="ui header side","This is the last side")
)
),
tags$button(id="test",class="ui button","Flip")
))
Server.R:
library(shiny)
library(shinyjs)
#devtools::install_github("Appsilon/shiny.semantic")
library(shiny.semantic)
#devtools::install_github("Appsilon/highlighter")
library(highlighter)
jsCode <- "
$('.shape').shape();
$('.shape').shape('flip up');
$('test').shape('flip up');
"
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
runjs(jsCode)
})
这会创建按钮和形状,但如何使按钮翻转形状?
答案 0 :(得分:1)
我认为你需要这个JS代码:
print(sorted(listik))
或者只是:
jsCode <- "
$('.shape').shape();
$('#test').on('click', function(){$('.shape').shape('flip up');});
"
和ui:
jsCode <- "
$('.shape').shape();
"