Last active
July 24, 2020 16:01
-
-
Save mattantonelli/96b9c7b1e30aa1f2cfc6095d0c8201b9 to your computer and use it in GitHub Desktop.
JQuery script for initializing a daterangepicker. Replaces "cancel" with a "clear" functionality. Removes default value. https://www.daterangepicker.com/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function() { | |
| $('.date-range').daterangepicker({ | |
| autoUpdateInput: false, | |
| timePicker: true, | |
| timePickerSeconds: true, | |
| locale: { | |
| cancelLabel: 'Clear', | |
| format: 'YYYY-MM-DD HH:mm:SS' | |
| } | |
| }); | |
| $('.date-range').on('apply.daterangepicker', function(_, picker) { | |
| $(this).val(picker.startDate.format(picker.locale.format) + ' - ' + picker.endDate.format(picker.locale.format)); | |
| }); | |
| $('.date-range').on('cancel.daterangepicker', function(_, _) { | |
| $(this).val(''); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment