How to select a dynamic instance of datepicker to expand it with jQuery

I am trying to control the positioning of a datepicker jQuery element. I like the solution suggested in How to control jQueryUI datepicker positioning to override _checkOffset fn:

$.extend(window.DP_jQuery.datepicker,{_checkOffset:function(inst,offset,isFixed){return offset}});

However, this leads to the error 'window.DP_jQuery undefined'. After checking, I see that the DP_jQuery object in the DOM gets a name with a random string, for example: DP_jQuery_123456. If I use this full name in the above code, it works fine.

My question is, is there a way to extract _checkOffset fn for a datepicker instance without knowing in advance what the instance name is? For example, is it possible to use some kind of template to select all instances of the date picker starting with "DP_jQuery _"?

thank

+3
source share
1 answer

Ok, I figured it out. The best way to do this is:

$.extend($.datepicker,{_checkOffset:function(inst,offset,isFixed){return offset}});

If I understand correctly, window.DP_jQuery_123456 is a pointer to an object / function of $ .datepicker. So the easiest way is to extend the real object, rather than trying to figure out the name of the pointer to the object.

+2
source

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


All Articles