jquery datepicker prevent native click in onSelect
Asked Answered
M

2

6

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 ?

Multiversity answered 28/12, 2010 at 19:39 Comment(4)
preventDefault is the right solution.. What exactly are you trying to find?Forcemeat
I have no idea how to access event object inside onSelectMultiversity
By prevent "click" you mean prevent populating the selected date to get populated to the input field that Datepicker is attached to?Lisalisabet
Not exactly, by default Datepicker "dates" are being highlighted onClick, I just want adllow/prevent highlighting on my custom condition inside Datepicker.onSelect Sure, I could bind some "independent" onclick handler "outside Datepicker namespace", but it would be some ugly solution - an unnecessary dependency.Multiversity
B
1

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

Bedelia answered 4/2, 2011 at 20:45 Comment(0)
K
1

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

Ketcham answered 18/6, 2011 at 10:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.