Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current active instance of jquery datepicker

I have multiple datepicker controls on single page binded to input controls. When I click on any of the input control datepicker control linked to that input gets visible.

Now I want to get input for which the current instance of datepicker is being shown on another JS events. Is it possible?

like image 594
Kiran Ramchandra Parab Avatar asked Dec 04 '15 12:12

Kiran Ramchandra Parab


1 Answers

You can try using the $.datepicker._getInst(target) method to get any specific datepicker on your page. You just have to pass in a target element, which you can do so by just passing the id using document.getElementById (don't use JQuery or it will return undefined).

So like so:

var id = document.getElementById('someId'); 
//replace someId with the id of the datepicker currently visible.  
var inst = window.$.datepicker._getInst(id);

This is especially helpful if you are trying to get the current instance of a datepicker that's an inline element (not attached to an input).

like image 116
vijayxtreme Avatar answered Oct 19 '22 03:10

vijayxtreme