I’m using the anytime.js datepicker library of a WordPress plugin that was custom-developed for me. I say that because I’m not the original developer and I’m afraid to rip out the library and replace it in case it means replacing lots of calls to functions that are exclusive to that library.
You can see that library here: http://www.ama3.com/anytime/
Unfortunately, the library is breaking some key functionalities of the WordPress backend as of version 3.3. I have confirmed that disabling the library completely fixes the problem.
Google Chrome’s console throws the following error:
Uncaught TypeError: Cannot read property 'left' of null
AnyTime.picker.__pickers.(anonymous function).posanytime.js:3032
AnyTime.picker.__pickers.(anonymous function).initializeanytime.js:1858
f.event.dispatchload-scripts.php:3
f.event.add.h.handle.iload-scripts.php:3
f.event.triggerload-scripts.php:3
f.fn.extend.triggerHandlerload-scripts.php:3
(anonymous function)load-scripts.php:3
f.Callbacks.nload-scripts.php:2
f.Callbacks.o.fireWithload-scripts.php:2
e.extend.readyload-scripts.php:2
c.addEventListener.B
in the following lines (3027 – 3039) of anytime.js line 3032 var left = off.left is the offending line of code according to the console:
if ( this.pop )
{
var off = this.inp.offset();
var bodyWidth = $(document.body).outerWidth(true);
var pickerWidth = this.div.outerWidth(true);
var left = off.left;
if ( left + pickerWidth > bodyWidth - 20 )
left = bodyWidth - ( pickerWidth + 20 );
var top = off.top - this.div.outerHeight(true);
if ( top < 0 )
top = off.top + this.inp.outerHeight(true);
this.div.css( { top: String(top)+'px', left: String(left<0?0:left)+'px' } );
}
Does anyone have suggestions for how to debug this?
The problem is that the page is trying to create pickers for fields that do not exist. The cause of the problem is not within anytime.js, but is instead inside of the inline script (specifically, edit.php lines 54 and 55 as reported by the browser).
It appears that the same picker-creating code is being called for every page, whether the date fields are present or not. The page should not try to create a picker for a field that does not exist!