开发者

forcing jquery ui datepicker to close / not popup

I have a jquery ui datepicker in a dialog and I noticed when I close the dialog it sometimes sticks around.

I tried to do

 $('#ui-datepicker-div').hide();

but that does not seem to hide it all.

I see there is a dialog option but I have no clue if that is what I need or how to use it

dialog

.datepicker( "dialog" , date , [onSelect] , [settings] , [pos] )

Open a datepicker in a "dialog" box.

dateText: the initial date for the date picker as either a Date or a string in the current date format.

onSelect: A callback function when a date is selected. The function receives the date text and date picker in开发者_运维百科stance as parameters.

settings: The new settings for the date picker.

pos: The position of the top/left of the dialog as [x, y] or a MouseEvent that contains the coordinates. If not specified the dialog is centered on the screen.

Also sometimes when I open the dialog the datepicker opens up and is in like the left hand corner of my screen under the dialog.

I believe that is because I populate a default value but I do it through the datepicker so I am not sure why it is poping up sometimes and sometimes it does not

  $('#datepicker').datepicker("setDate", '+1d')


Its better to use .remove() instead of .hide() in scenarios where you are crating new instances.

Or better way: Use datepicker's method like .datepicker("hide") .. you can see it at documentation.


You can also implement this using css. It is not the optimal way of doing it, but it surely does the job for you.

$('#datepicker').css('visibility','hidden');
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜