开发者

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

I am using "simple jQuery date-picker". 开发者_如何学CI 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!


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜