title: R shinyBS popup window
body: <p>I working on a project where I have to create a form in shiny. I currently have a datatable in the UI which has email in the form of hyperlink. Once the hyperlink is clicked the modal window opens where I have another UI which shows the various fields to be filled. I have a save button here that should update my DB in the backend once the button is clicked. </p>
  
  <p>The problem I am facing is that I am unable to reference each email to that particular modal window and my update query updates all the records in the DB. Is there a way to pass all the record details that has been clicked into the modal window??</p>
  
  <p>What I basically need to know is how to update the record that I have clicked on and for which the pop up window is opened??</p>
  
  <p>I am attaching the UI.R and server.R for use. </p>
  
  <pre><code>enter code here
  </code></pre>
  
  <p>ui.R</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>library(shiny)
  library(DT)
  library(shinyBS)
  fluidPage(
           fluidRow(
                    actionButton(inputId = "view",label = "Hi")),
                    #actionButton(inputId =  "savepage1", label = "Save"),
                    DT::dataTableOutput('my_table'),
                    bsModal("FormModal", "My Modal", "",textOutput('mytext'),uiOutput("form1"),
                            actionButton("savepage2","Save"),DT::dataTableOutput("table1"),size = "large")
  
           )</code></pre>
  </div>
  </div>
  </p>
  
  <pre><code>enter code here
  </code></pre>
  
  <p>server.R</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>library(shinyBS)
  server &lt;- function(session, input, output){
    
  uedata&lt;-c("","Prime","Optimus")  ##add source data here
    
    output$form1&lt;-renderUI({
      tagList(
        column(width=6,selectInput("samplevalue","Select Custom Source*",choices=c("Please select",samplevaluedata))),
        column(width=6,textInput("sampletext",label = "Enter Text",value = NULL,placeholder = NULL)))
    })
  
    on_click_js = "Shiny.onInputChange('mydata', '%s');
    $('#FormModal').modal('show')"
    
    convert_to_link = function(x) {
      as.character(tags$a(href = "#", onclick = sprintf(on_click_js,x), x))
    }
    
    observeEvent(input$view,{
      session$sendCustomMessage(type = "unbinding_table_elements", "my_table")
      output$my_table &lt;- DT::renderDataTable({
        a=dbGetQuery(hcltcprod,paste0("select name,mobile,email,assignedto from public.tempnew order by 3;"))
        a &lt;- data.frame(a,row.names = NULL)
        a$email &lt;- sapply(a$email,convert_to_link)
        a1 &lt;- datatable(a,
                       escape = F,
                       options = list(paging = FALSE, ordering = FALSE, searching = FALSE, rownames = FALSE,
                                      preDrawCallback = JS('function() { Shiny.unbindAll(this.api().table().node());}'),
                                      drawCallback = JS('function() { Shiny.bindAll(this.api().table().node()); } ')))
                                      
        a1
      })
    })
    
    observeEvent(input$my_table_cell_clicked, {
      print(Sys.time())
    })
  
    observe({
      if(input$savepage2==0)
        return()
      isolate({
        for(i in 1:nrow(a))
       dbGetQuery(hcltcprod,paste0("update public.tempnew set s_text='",input$samplevalue,"',s_value='",input$sampletext,"' where mobile in ('",a$email,"');"))
      })
    })
    
  }</code></pre>
  </div>
  </div>
  </p>