I'm trying to control positioning of a jQuery datepicker element开发者_开发技巧. I like the solution offered at How to control positioning of jQueryUI datepicker for overriding the _checkOffset fn:
$.extend(window.DP_jQuery.datepicker,{_checkOffset:function(inst,offset,isFixed){return offset}});
However, this results in a 'window.DP_jQuery is undefined' error. Upon inspection, I can see that the DP_jQuery object in the DOM gets named with a random string, like so: DP_jQuery_123456. If I use this full name in the above code, it works wonderfully.
My question is whether there's a way to exend the _checkOffset fn for a datepicker instance without knowing before-hand what the instance name is? For example, can I use some sort of wildcard to select all datepicker instances that begin with 'DP_jQuery_'?
Thanks
Okay, I figured this out. The best way to do this is like so:
$.extend($.datepicker,{_checkOffset:function(inst,offset,isFixed){return offset}});
If I understand correctly, window.DP_jQuery_123456 is a pointer to the object/function $.datepicker. So it's simply easiest to extend the actual object, rather than try to figure out the name of the pointer to the object.
精彩评论