闪亮-自动跳至新的附加标签

时间:2019-01-24 06:25:09

标签: r shiny

我很难让我的应用在点击其中一个标记后创建后自动跳至新的附加标签。

library(shiny)
library(leaflet)
library(shinydashboard)


pts <- data.frame(
  id= letters[seq( from = 1, to = 10 )],
  x = rnorm(10, mean = -93.625), 
  y = rnorm(10, mean = 42.0285)
)


# Define UI 
ui <- fluidPage(

  tabsetPanel(id='my_tabsetPanel',
              tabPanel('Map1',
                       leafletOutput('map1')   
              )
  )
)

server <- function(input, output, session) {

  output$map1 <- renderLeaflet({
    leaflet() %>% 
      addTiles() %>% 
      setView(-93.65, 42.0285, zoom = 6)
  })


  observe({

    input$my_tabsetPanel

    tab1 <- leafletProxy('map1', data = pts) %>%
      clearMarkers() %>% 
      addCircleMarkers(lng = ~x, lat = ~y, radius = 4, layerId = ~id)


  })


observeEvent(input$map1_marker_click, { 
  tab_title <- input$map1_marker_click[1]
  appendTab(inputId = "my_tabsetPanel",
            tabPanel(
              tab_title,
              fluidRow(

                box('test')
                )))

  updateTabsetPanel(session, "my_tabsetPanel", selected = tab_title)

})

}


shinyApp(ui = ui, server = server)

我希望应用程序自动跳到新标签页,但是我想我不使用updateTabsetPanel正确

示例代码的信用部分从link

被盗

1 个答案:

答案 0 :(得分:2)

问题在于您设置tab_id的方式。一定有一些冲突。

onSubmit(){
    if(!validateCondition1){
        enter code here
        return false;
    }
    if(!validateCondition2){
        enter code here
        return false;
    }
     ....submit code.....
}
_.isEqualWith(array, other, (objValue, othValue) => {
  if(objValue.id === otherValue.id && objValue.name === otherValue.name){
   return true'
  }
})