Comments (5)
You don’t need renderUI because insertF7Tab can be used from the server, allowing you to create your tab from the server, for any tab.
from shinymobile.
from shinymobile.
Hi,
The issue is coming from the renderUI
where you generate the tabs. Is there a reason for this?
Taking the simple example from the documentation, which runs fine:
library(shiny)
library(shinyMobile)
library(shinyWidgets)
shinyApp(
ui = f7Page(
title = "Tab layout",
f7TabLayout(
tags$head(
tags$script(
"$(function(){
$('#tapHold').on('taphold', function () {
app.dialog.alert('Tap hold fired!');
});
});
"
)
),
panels = tagList(
f7Panel(title = "Left Panel", side = "left", theme = "light", "Blabla", effect = "cover"),
f7Panel(title = "Right Panel", side = "right", theme = "dark", "Blabla", effect = "cover")
),
navbar = f7Navbar(
title = "Tabs",
hairline = FALSE,
shadow = TRUE,
leftPanel = TRUE,
rightPanel = TRUE
),
f7Tabs(
animated = FALSE,
swipeable = TRUE,
f7Tab(
tabName = "Tab1",
icon = f7Icon("envelope"),
active = TRUE,
f7Shadow(
intensity = 10,
hover = TRUE,
f7Card(
title = "Card header",
f7Stepper(
"obs1",
"Number of observations",
min = 0,
max = 1000,
value = 500,
step = 100
),
plotOutput("distPlot1"),
footer = tagList(
f7Button(inputId = "tapHold", label = "My button"),
f7Badge("Badge", color = "green")
)
)
)
),
f7Tab(
tabName = "Tab2",
icon = f7Icon("today"),
active = FALSE,
f7Shadow(
intensity = 10,
hover = TRUE,
f7Card(
title = "Card header",
f7Select(
inputId = "obs2",
label = "Distribution type:",
choices = c(
"Normal" = "norm",
"Uniform" = "unif",
"Log-normal" = "lnorm",
"Exponential" = "exp"
)
),
plotOutput("distPlot2"),
footer = tagList(
f7Button(label = "My button", href = "https://www.google.com"),
f7Badge("Badge", color = "orange")
)
)
)
),
f7Tab(
tabName = "Tab3",
icon = f7Icon("cloud_upload"),
active = FALSE,
f7Shadow(
intensity = 10,
hover = TRUE,
f7Card(
title = "Card header",
f7SmartSelect(
inputId = "variable",
label = "Variables to show:",
c("Cylinders" = "cyl",
"Transmission" = "am",
"Gears" = "gear"),
multiple = TRUE,
selected = "cyl"
),
tableOutput("data"),
footer = tagList(
f7Button(label = "My button", href = "https://www.google.com"),
f7Badge("Badge", color = "green")
)
)
)
)
)
)
),
server = function(input, output) {
output$distPlot1 <- renderPlot({
dist <- rnorm(input$obs1)
hist(dist)
})
output$distPlot2 <- renderPlot({
dist <- switch(
input$obs2,
norm = rnorm,
unif = runif,
lnorm = rlnorm,
exp = rexp,
rnorm
)
hist(dist(500))
})
output$data <- renderTable({
mtcars[, c("mpg", input$variable), drop = FALSE]
}, rownames = TRUE)
}
)
If you had to dynamically add/remove tabs to be able to programmatically create them, which is possible, you would have to leverage some tabs related server functions like shinyMobile::insertF7Tab
, shinyMobile::removeF7Tab
:
library(shiny)
library(shinyMobile)
shinyApp(
ui = f7Page(
title = "Insert a tab Before the target",
f7TabLayout(
navbar = f7Navbar(
title = "insertF7Tab",
hairline = FALSE,
shadow = TRUE,
leftPanel = TRUE,
rightPanel = TRUE
),
f7Tabs(
animated = TRUE,
id = "tabs",
f7Tab(
tabName = "Tab1",
icon = f7Icon("airplane"),
active = TRUE,
"Tab 1",
f7Button(inputId = "add", label = "Add tabs")
),
f7Tab(
tabName = "Tab2",
icon = f7Icon("today"),
active = FALSE,
f7Button(inputId="stay", label = "Stay"),
"Tab 2"
)
)
)
),
server = function(input, output, session) {
observeEvent(input$stay, {
f7Toast("Please stay")
})
observeEvent(input$add, {
insertF7Tab(
id = "tabs",
position = "after",
target = "Tab1",
tab = f7Tab (
# Use multiple elements to test for accessor function
f7Text(inputId = "my_text", label ="Enter something", placeholder = "What?"),
f7Text(inputId = "my_other", label ="Else:", placeholder = "Else ?"),
tabName = paste0("tabx_", input$go),
"Test2",
icon = f7Icon("app_badge")
),
select = TRUE
)
})
}
)
from shinymobile.
Hi , DivadNojnarg
thank you very much, shinyMobile::insertF7Tab, shinyMobile::removeF7Tab is a good solution.
but, I must use renderUI, because The content of each tab is generate from the server,thank you very much!
If I must use renderUI, is there any suggestion?
from shinymobile.
great ,I will test insertF7Tab in my app,thank you very much!
from shinymobile.
Related Issues (20)
- some error when use app_container function HOT 1
- Stylesheet not load... sometimes. Works on refresh page... sometimes. HOT 1
- General error on `f7Popup()` function HOT 1
- about Authentication HOT 2
- Tab labels not showing HOT 2
- How to run shinymobile in desktop as mobile app HOT 1
- Is it possible to use validateF7Input() on an input rendered on the server using renderUI() ? HOT 2
- Is this project still alive? HOT 2
- f7DatePicker is off by one day
- height parameter doesn't work on r7ExpandableCard HOT 1
- Installation issue in versions < R4.1 will have error because of \() usage
- Missing class in f7Progress for infinite progress bar
- Can I publish the application to the app store or Google Play HOT 2
- `f7Stepper` doesn't work within a `f7Popup`. HOT 1
- After upgrading to 2.0, updateF7Login doesn't work! HOT 2
- close popup upon clicking f7Button within popup HOT 1
- f7Radio Buttons Horizontally
- Service worker and manifest not being appropriately moved for pwa with bundle_resources HOT 2
- f7LoginServer is not recommended for production. What to use instead?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shinymobile.