monim67 / django-bootstrap-datepicker-plus

Bootstrap3/Bootstrap4/Bootstrap5 DatePickerInput, TimePickerInput, DateTimePickerInput, MonthPickerInput, YearPickerInput with date-range-picker functionality for django >= 2.0
https://pypi.python.org/pypi/django-bootstrap-datepicker-plus
MIT License
223 stars 61 forks source link

`dp.change` event doesn't seem to be emitted #120

Open egor83 opened 4 weeks ago

egor83 commented 4 weeks ago

Describe the bug Changing values in the datetime picker input emits change event, but not the dp.change.

I recently updated our project's django-bootstrap-datepicker-plus version from 4.0.0 to 5.0.5. After that, the code that listened to dp.change event has stopped working. In the MRE, I added a JS function to change the end datetime value to start datetime value + 30 minutes (see base_app/templates/base_app/index.html, line 25).

But basically, this snippet shows what's wrong:

    $("#id_start_datetime").on("dp.change", function() {console.log("dp.change");});
    $("#id_start_datetime").on("change", function() {console.log("change");});

The second line works (once I change the value and press "Enter"); the first one does not.

To Reproduce Steps to reproduce the behavior:

  1. Unpack the attached MRE.
  2. Run python manage.py runserver
  3. Go to http://localhost:8000
  4. Click on the "start datetime" field and change its value.

Expected behavior I expect the end datetime value to change to the start datetime + 30 minutes. It does work initially, the end datetime value is set to the start datetime + 30 minutes. It does NOT change when I change the start datetime value using datepicker controls. If I change the value manually and press "Enter", the change event is emitted and the end datetime is changed (as it should).

Setup Information (please complete the following information):

[x] I have followed the configuration instructions and checked out the common error troubleshooting page: "configuration instructions" page returns 404 (also in the docs), but I have checked the troubleshooting page.

egor83 commented 4 weeks ago

PS I included the workaround for the issue #116 described here.

egor83 commented 4 weeks ago

PPS Forgot to attach the MRE: datepicker_bug_mre_20240816.zip

egor83 commented 3 weeks ago

(Downgrading back to 4.0.0 solved the problem.)