• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

My Monkey Do

A Log of Coding Solutions

  • Home
  • Web Hosts
  • Tools
  • About

Fancybox and Datepicker Error

August 27, 2013 by Webhead

Problem

Using fancybox and datepicker I got an “a is undefined” javascript error.  I added datepicker to the fancybox by using the following code:  

$('#fancybox-wrap').on('focusin', '.datepicker', function(e) {
$(this).datepicker();
 });

This caused the datepicker to show up correctly, but when selecting a date it closed the fancybox modal while leaving the greyed background.

 

Solution

I am always amazed at how often I find solutions on StackOverflow.  Even if the OP didn’t have my exact problem, the solution given solved my problem.   Because fancybox (in general all lightboxes) duplicates the DOM datepicker gets confused on which calendar modal to close.  The solution is as follows:

$('#fancybox-wrap').on('focusin', '.datepicker', function(e) {
$(this).attr("id","datepickerNEWID");
$(this).datepicker();
 });

http://stackoverflow.com/questions/3392961/jquery-datepicker-does-not-work-inside-lightbox

 

 

Filed Under: Coding Tagged With: jquery

Primary Sidebar

Topics

apache apple block editor chrome cms css debug eCommerce embed firebug firefox git gmail goDaddy google hosting htaccess html html 5 IE crap image iPad iPhone javascript jquery linux localization mac os x ms sql mysql open source optimize php php 5.3 responsive rest api seo svg tinymce woocommerce wordpress wpengine xss yii youtube




Categories

  • Coding
  • Off the Shelf
  • Plugins
  • Random Thoughts
  • Server Stuff
  • Tools