fragaria / angular-daterangepicker

Angular.js wrapper for dangrossman/bootstrap-daterangepicker
MIT License
519 stars 371 forks source link

After clearing, cannot "apply" already selected dates again #82

Closed bsk0 closed 9 years ago

bsk0 commented 9 years ago

If I select a date range and apply, then clear, hitting apply again on the date range produces no effect. I have to manually change the date range to some other value in order to have the apply take effect.

kijanawoodard commented 9 years ago

+1

bsk0 commented 9 years ago

The issue should be closed--- I think I was using the directive inappropriately. The real way to act on changes to the date range model are not to link an event watcher to the model, but rather to setup a listener on the "apply" event as an attribute to the directive declaration.

kijanawoodard commented 9 years ago

The problem we're seeing is that if the user clears the date manually, the control still thinks the previous date is still selected and won't let you select it again.

In the simple case, if the model is set to null, you can't pick "today" because it's already selected in the control.

bsk0 commented 9 years ago

But the apply event still fires when the apply button is click, right? Can't you use an event trigger to perform whatever functionality is required on the date selection on the apply event?

mschaeuble commented 8 years ago

Catching the event doesn't work neither because the arguments are not passed properly. See also my comment in https://github.com/fragaria/angular-daterangepicker/issues/119

I think the issue described here is still present: there is no change on the model after hitting apply the second time and therefore, this issue should be reopened. The reason for this is behaviour is because the callback method passed in the following code snippet is not called in the case described above:

el.daterangepicker angular.extend(opts, {autoUpdateInput: false}), (start, end) ->
        $scope.$apply () ->
          $scope.model = if opts.singleDatePicker then start else {startDate: start, endDate: end}

I could imagine that the callback method is not called because there is no change in the selected value (because the original intention of the 'clear' button is 'cancel'). Therefore, I think the implementation of angular-daterangepicker should be adapted in a way that the events 'apply.daterangepicker' and 'cancel.daterangepicker' are evaluated instead of relying on the callback function.