amsul / pickadate.js

The mobile-friendly, responsive, and lightweight jQuery date & time input picker.
http://amsul.ca/pickadate.js
MIT License
7.7k stars 1.01k forks source link

Event OnClear #1076

Closed brunoMachado92 closed 6 years ago

brunoMachado92 commented 6 years ago

Hello,

On clear, i need to set the highlight date to today's date for the user when opens the calendar next time see today's date selected.

There is any event called OnClear? If not, whats the workarround for this ?

Cheers!

brunoMachado92 commented 6 years ago

i found a workarround for this: picker.on({ set: function(thingSet) { if(thingSet['clear']===null) picker.set('highlight', ...); } }) still, i think it would be a nice option

spletjesvet commented 1 year ago

Its a shame that there is no onClear event handler, would make things so much easier. Still, thankful for the plugin, dont get me wrong :). What i did was:

$('.picker__button--clear').on('click', function(e) { var elementId = $(this).attr("aria-controls"); var aData = $('#'+elementId).data(); aData[elementId] = ''; // Ajax call ... });

Caveat: had to re add the event handler every time i clicked the clear button, not sure why, probably the plugin unbinds events. Hope it helps someone.