Override jQuery UI DatePicker _generate HTML function

In jQuery UI 1.7, I successfully redefined the datepicker._generateHTML function by running a script in the form:

jQuery.datepicker._generateHTML = function(inst) {
  ...revised code...
};

When I tried to upgrade to version 1.8 using the same approach, I ran into a problem. Version 1.8 added a variable for the dampiker's closing area dpuuid, which is referenced by the new version of "... modified code ...". datepicker._generateHTML now fails with dpuuid is not defined' error.

I'm still young enough that Javascript does not understand all the subtle aspects of the language. So my first question is: "Is it possible to override a function that refers to a variable of a closure scope and still access the original closure area?"

+3
source share
1 answer

I found the answer in Thomas answer for jQuery DatePicker how to turn off automatic day selection while viewing a calendar?

Adding the following to the beginning of my "... recycled code ...":

  if (!inst.dpuuid) {
    for (attr in window) {
      if(/^DP_jQuery_/.test(attr)) {
        inst.dpuuid = attr.replace(/^DP_jQuery_([0-9]+)/, '$1');
      }
    }
  }
  var dpuuid = inst.dpuuid;

deleted dpuuid is not defined' error. I saw in FireBug that the closing area is visible from the window object, but had no idea how to extract value from it.

Thanks to Thomas !!

0
source

All Articles