spongessuck / gm.datepickerMultiSelect

AngularJS module to extend UI Bootstrap's Datepicker directive to allow for multiple date selections.
MIT License
73 stars 41 forks source link

Datepicker doesn't display the selected days #59

Closed sky3913 closed 7 years ago

sky3913 commented 7 years ago

I have add a button to set some of selected days when it's clicked, but it doesn't render the selected days correctly until I select another days. For example when I click the button I will set 11, 13, 15 May 2017 as the selected days, as shown by this code:

html <button ng-click='$ctrl.setDate()'>Set Dates</button>

js

this.setDate = function() {
    _this.selectedDates = [
      new Date('2017-05-11').setHours(0, 0, 0, 0),
      new Date('2017-05-13').setHours(0, 0, 0, 0),
      new Date('2017-05-15').setHours(0, 0, 0, 0)];
  }

The datepicker doesn't set the date of 11, 13, and 15 in blue highlighted background color, but if you click another days for example, 20 May 2017 then the datepicker will set the 11, 13, 15, and 20 in blue highlighted.

Furthermore, if you unselect the 20 May 2017 by clicking it once again and click the Set Dates's button you cannot select another days.

Here is the plunker to show the problem: http://plnkr.co/edit/yUyYcANwSxtmpTsgCmi1?p=preview

spongessuck commented 7 years ago

I found a workaround for the 'setting dates not updating view' issue in #57. Please see the following plunk for a fix:

http://plnkr.co/edit/jhJ8KWqAb7aX1pqqZ7xy?p=preview

The second issue is a puzzler. I'd have to dig further to find out what's going on.