ductinh2405
ductinh2405

Reputation: 21

Close "simple jQuery date-picker" when click outside it?

I am using "simple jQuery date-picker". I try to edit the js to close it when visitor click outside it.

The js is at: http://teddevito.com/demos/calendar.php

In js file, I see the line to close it when click in close text: jQuery("span.close", datepicker).click(function () { closeIt($this, datepicker); });

I append this line but it don't work: jQuery("body").click(function () { closeIt($this, datepicker); });

Please help me! Thank so much!

Upvotes: 0

Views: 2856

Answers (1)

netoper
netoper

Reputation: 153

I had the same problem. Here is my solution:

find in the js line 230

...
// open a datepicker on the click event
jQuery(this).click(function (ev) {

var $this = jQuery(ev.target);
...

add ev.stopPropagation(); after jQuery(this).click(function (ev) {

...
// open a datepicker on the click event
jQuery(this).click(function (ev) {

ev.stopPropagation();

var $this = jQuery(ev.target);
...

and then add these two new lines after jQuery("span.close", datepicker).click(function () { closeIt($this, datepicker); }); at line 213

jQuery(datepicker).click(function() { return false; });
jQuery('html').click(function() { closeIt($this, datepicker); });

good luck

Upvotes: 1

Related Questions