Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQueryUI datepicker widget add 'onClose' function after widget initialization

Let's say I have a #date field. At first I initialize it with some options (they are not important at the moment):

$('#date').datepicker(options);

Then, if I try to add onClose function, I would do:

$('#date').datepicker({onClose: function(dateText, inst){console.log("Hello World");}});

Howerver, this overrides options set before. Let's say I don't have access to these options - datepicker is initialized, options are set and now I need to add function onClose. How to do that? I've tried .datepicker('option','onClose',function(){}); with no effect.

like image 755
alekwisnia Avatar asked Mar 07 '13 11:03

alekwisnia


People also ask

How do I change the Datepicker format?

An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field.

How do I make my Datepicker always visible?

Simply call . datepicker() on a div instead of an input. (To display the datepicker embedded in the page instead of in an overlay.) Save this answer.

How can I get current date in Datepicker?

You can set the current date value in DateTimePickerAdv by disabling the IsNullDate property and set the DateTimePickerAdv value as current date.


2 Answers

Try it as

$('#date').datepicker( 'option' , 'onClose', function() {} );
like image 161
Ajo Koshy Avatar answered Oct 17 '22 04:10

Ajo Koshy


Try this:

$('#date').datepicker();
...
$('#date').datepicker("option", {
  onClose: function(dateText, inst){console.log("Hello World");}
});

Of course this would override the previous onClose function you've set before. source: jQuery forum post

like image 33
MarcoL Avatar answered Oct 17 '22 05:10

MarcoL