1

I would like to make redirect when a date is changed and transmit selected date parameter (via window.location.href). I'm using Bootstrap Date Paginator, which contains Bootstrap datepicker, but I don't know how to change these lines of code to work properly:

this.$calendar
  .datepicker({
    options...
  })
  .datepicker('update', this.options.selectedDate.toDate())
  .on('changeDate', $.proxy(this._calendarSelect, this));

I know I would use changeDate event but there aren't any examples of using this event. Can you help me, please?

KRiSTiN
  • 429
  • 1
  • 4
  • 11

2 Answers2

0

Would this do?

You can use .on('change', ..) like this,

this.$calendar
  .datepicker({
    options...
  }).on('change', function() {
       var changedDate = this.$calendar.val();
       //alert("value of date is "+ x);
    var theUrl = 'your URL';
    window.location.href = theUrl+"date="changedDate
    });

Else use, on('change.dp', ..) event like this,

this.$calendar
      .datepicker({
        options...
      }).on('change.dp', function() {
           var changedDate = this.$calendar.val();
           //alert("value of date is "+ x);
        var theUrl = 'your URL';
        window.location.href = theUrl+"date="changedDate
        });

Alternatively have a look at this too.

Community
  • 1
  • 1
Sudhansu Choudhary
  • 3,322
  • 3
  • 19
  • 30
0

May be it's too late, but I have same problem and come up with this solution, while setting options for Bootstrap Date Paginator keep track of onSelectedDateChanged function and assign the date value to a variable and send that variable to location.href.

            <script>
            var currDate = new Date();
            var options = {
                           selectedDateFormat: 'DD/MM/YYYY',
                           selectedDate: moment(currDate).format('DD/MM/YYYY'),
                           onSelectedDateChanged: function (event, date) {
                                     var dateSelected = moment(date).format('DD/MM/YYYY');
                                     location.href = '/ServletName?timestamp='+currDate .getTime() + "&date=" + dateSelected ;
                               },
                           };

             $('#paginator').datepaginator(options);

         </script>
         <body>
                <div id="paginator"></div>
         </body>
Gopikrishn
  • 35
  • 1
  • 16