我有奇怪的错误。所有需要我的库都包含在theri网站上,但它仍然不起作用。为什么?我错过了什么? 在控制台我有
Index.chstml
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<script src="~/Scripts/jquery-2.2.0.min.js"></script>
<script src="~/Scripts/moment.min.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
<script src="~/Scripts/bootstrap-datetimepicker.min.js"></script>
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
<link href="~/Content/bootstrap-datetimepicker.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class='col-sm-6'>
<div class="form-group">
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<script type="text/javascript">
$('#datetimepicker1').datetimepicker({ useCurrent: false });
$('#datetimepicker1').on("dp.hide", function (e) {
$.ajax({
url: "/Home/Index",
type: "POST",
data: { test: $('#datetimepicker1').data('DateTimePicker').date().format('YYYY-MM-DD HH:mm') },
success: function (response) {
$('.results').html(response);
}
});
debugger;
});
</script>
</div>
控制器:
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
[HttpPost]
public JsonResult Index(DateTime? test)
{
return Json("1");
}
}
答案 0 :(得分:0)
尝试
使用更改事件
jchar *xor
答案 1 :(得分:0)
首先,如果将jquery放在app文件夹中,请添加Jquery文件链接
添加jquery datepicker文件
<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>
&#13;
现在写下面的代码:
$("#datetimepicker1").datepicker(
{
changeMonth: true,
changeYear: true,
dateFormat: 'mm/dd/yy',
yearRange: "-80: +0",
setDate: new Date()
}
答案 2 :(得分:0)