jquery datepicker prevent native click in onSelect

2019-02-22 03:46发布

问题:

I'm in struggle trying to prevent native click inside jquery datepicker.onSelect event

Example below is not working, click still is being triggered:

onSelect: function(dateText, inst) { 

if (myCondition) {
   return false; 
 }}

Another trick would be calling event.preventDefault/ inside onSelect, if event object has been available.

Any known solutions ?

回答1:

Perhaps you can achieve this via CSS instead of binding to events?



回答2:

What if you used the beforeShow event ? as referenced here http://jqueryui.com/demos/datepicker/#event-beforeShow

This way, you could really prevent the datepicker from being displayed.

Regards,

Max