How to determine which datepicker widget is open to

This question is similar to Check if the datepicker is open , except that it refers to a page that has several date controls.

When there are multiple datepickers on the page, the jQuery user interface appears only to create one datepicker widget, which will be shared with all dumpers.

I am trying to find a way through the datepicker user interface or otherwise to find out which datepicker is open for the widget. Unfortunately, tested and verified tests, such as:

$('#someDatepicker').datepicker('widget').is(':visible'); 

returns true no matter what datepicker is open for the widget, if it is visible somewhere.

+4
source share
1 answer

After scanning through the source code for datepicker, I found some related code on line 718:

 inst = $.datepicker._getInst(input); if ($.datepicker._curInst && $.datepicker._curInst !== inst) { ... } 

Using this code, I delved into these internal objects and hacked the fiddle . It looks like $.datepicker._curInst.id will provide you with the id of the text field for which the datepicker widget is open.

Use at your own risk, as the object is internal and undocumented and may be changed / moved / deleted in future versions of the library.

+4
source

Source: https://habr.com/ru/post/1481985/


All Articles