2015-04-01 92 views
0

在模态对话框中显示datepicker似乎有问题。在jQuery模式对话框中显示jQuery日期选取器

我使用:

$(".dpicker").datepicker({ 
     numberOfMonths: 2, 
     dateFormat: 'd M yy', 
     showButtonPanel: true 
    }); 

,以使在给定的输入栏的日期选择器。

请检查小提琴:

http://jsfiddle.net/ozjyu9k5/3/

它的工作,除了同时模态对话框呈现。

任何建议使datepicker在对话框中工作?

请不要标记为重复,因为我搜索整个互联网的工作解决方案,并没有一个似乎工作。

回答

-2

尝试使用JQuery UI日期选择器。见下面代码段(JsFiddle Demo):

HTML代码:

<p>HTML5 Date: <input type="date" placeholder="html5 date:" /></p> 

<p><input id="Button1" type="button" value="Get DatePicker Value" title="Get DatePicker Value" /></p> 

脚本

// Insert placeholder as prefix in the value, when user makes a change. 
$(".datepicker").datepicker({ 
    onSelect: function(arg) { 
     $(this).val($(this).attr("placeholder") + arg); 
    } 
}); 

// Display value of datepicker 
$("#Button1").click(function() { 
    alert('call val(): {' + $("input").val() + '}'); 
}); 

感谢,

〜CHANDAN

+0

这不是我想要的。我需要将它显示在模式对话框中,否则很容易。检查我的小提琴,已经做了你所做的。 – 2015-04-01 11:09:27

+0

@Liviuvalentyn查看此连结:http://jsfiddle.net/sudiptabanerjee/93eTU/ – 2015-04-01 11:19:48

+0

@Liviuvalentyn或使用Bootstrap在模态内显示datepicker,请参阅此链接:http:// codepen。io/Sinetheta/pen/Ftjwi – 2015-04-01 11:21:34

0

为什么不使用像this one这样的弹出窗口。您可以在official API page上看到完整的api。

它应该是这样的:

datepicker

当你在输入框中单击它会告诉你这样

datepicker open对话框

您的代码将是这样的:

<!doctype html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <title>jQuery UI Datepicker - Default functionality</title> 
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> 
    <script src="//code.jquery.com/jquery-1.10.2.js"></script> 
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> 
    <link rel="stylesheet" href="/resources/demos/style.css"> 
    <script> 
    $(function() { 
    $("#datepicker").datepicker(); 
    }); 
    </script> 
</head> 
<body> 

<p>Date: <input type="text" id="datepicker"></p> 


</body> 
</html> 
+0

是的,但我的问题是,在JQuery UI模式窗口中显示JQuery UI日期选择器不起作用。否则它的工作。 – 2015-04-07 03:25:04

0

我能够通过用下面的代替你包含的jQuery UI JS和CSS文件(外部资源)来获得在小提琴中工作的datepicker:

//code.jquery.com/ui/1.11.4/themes/平滑/ jQuery的ui.css

//code.jquery.com/ui/1.11.4/jquery-ui.js

相关问题