【发布时间】:2017-04-27 12:38:15
【问题描述】:
我在 if 语句中包含了我的 datepicker 输入,所以它不起作用。我不知道它是否因为 if 语句或其他原因而不起作用,但是当没有 if 语句时,datepicker 工作正常。脚本以正确的顺序包含在内,这很好。 jQuery 脚本:
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script>
$(function() {
$('#nextDate').datepicker({
dateFormat: "yy-mm-dd",
});
$("#currentDate").datepicker({
dateFormat: "yy-mm-dd",
minDate: 0,
onSelect: function(date){
var date2 = $('#currentDate').datepicker('getDate');
date2.setDate(date2.getDate()+7);
$('#nextDate').datepicker('setDate', date2);
}
});
});
</script>
日期选择器应该在的页面,如下所示:
if(Auth::user()->role == 2) { ?>
<form class="form-horizontal" method="POST" action="/rentals">
{{ csrf_field() }}
<div class="form-group">
<div class="col-sm-5 col-sm-offset-1">
<input class="form-control" type="text" id="currentDate" name="start">
</div>
<div class="col-sm-5">
<input class="form-control" type="text" id="nextDate" name="end">
</div>
</div>
<button type="submit" class="btn btn-success">Rent it</button>
</form>
<?php } ?>
【问题讨论】:
-
角色很好。我看到输入框,但是当我点击输入框时没有出现日期选择器。
-
不是真的,但是当我输入 jqueryUI include 时,它说它没有加载,但是当我删除 if 语句时,它仍然可以正常工作...
-
当我在控制台输入 $.ui 时,它说它没有加载
-
仍然没有解决我的问题.. :(
标签: php jquery laravel jquery-ui-datepicker