ebailey78 / shinyBS

Twitter Bootstrap Components for Shiny
182 stars 47 forks source link

bsModal close event? #39

Open happyshows opened 9 years ago

happyshows commented 9 years ago

Hi,

Is there any way to include some code in a close event of bsModal?

I wanted to do some cleanup job, like reset button status after user close the Modal.

shrektan commented 9 years ago

+1 I would vote for this idea.

lcabre-md commented 9 years ago

+1

ssifleet commented 8 years ago

+1

jeffjet24 commented 8 years ago

+1 as well

pekaalto commented 8 years ago

+1. Would be very useful

E: Here is one way to do it with the current version:


library(shiny)
library(shinyBS)

s = shinyServer(function(input,output,session){
  output$text = renderText({
    print(input$last_modal_close)
    sprintf('modal closed at %s',input$last_modal_close)
  })
})

u = shinyUI(fluidPage(
  tags$script('
  $( document ).ready(function() {
    $("#myModal").on("hidden.bs.modal", function (event) {
    x = new Date().toLocaleString();
    window.alert("Ok modal was closed at " + x);
    Shiny.onInputChange("last_modal_close",x);
  });
  })
  '),
  textOutput('text'),

  bsModal('myModal','Hi','trig','This is a modal'),
  a(href='#',onclick="$('#myModal').modal('show');",'click to open the model')
))

shinyApp(u,s)