r - Auto update my dateRangeInput at shinyR UI -


my shinyr app using daterangeinput selector default values of date range between yesterday , 15 days ago , when app running more on day , wish default date range update accordingly , know @ server side invoke invalidatelater , have no idea can done @ ui side of app , daterangeinput @ ui side looks :

daterangeinput('daterange',label = 'date',start = sys.date() - 15, end = sys.date()-1) 

okay, not sure why want on client side, there way. can add javascript on client construction invalidatelater do. gets more confusing server side version.

code below:

library(shiny)  ui <- shinyui(fluidpage(   daterangeinput('daterange',label = 'date',start = sys.date() - 15, end = sys.date() - 1),   tags$script(html("     $(document).ready(function() {       var initdate = new date();        setinterval(function() {         var currentdate = new date();         if(currentdate.getdate() != initdate.getdate()) {           initdate = currentdate;            var start = new date();           start.setdate(currentdate.getdate() - 15);            var end = new date();           end.setdate(currentdate.getdate() - 1);            /* insert id of daterangeinput */           var dateinput = $('#daterange').find('input');           dateinput.eq(0).datepicker('update', start);           dateinput.eq(1).datepicker('update', end);         };       /* insert interval in millis below. */       }, 3600000);     });   ")) ))  server <- function(input, output, session){}  shinyapp(ui, server) 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -