這可能只是一個簡單的錯誤,但我花了最後3個小時試圖弄清楚 - 沒有成功。jQuery Datepicker中的onSelect事件似乎不會觸發
我最終想做的是使用輸入的日期,並將其與截止日期進行比較,以表明提交是否爲時過晚。但是,目前爲了簡化目的,我只想告訴我日期已經改變,但沒有成功。我在哪裏錯了?
$("#id_submission_date").datepicker({
onSelect: function(dateText) {
$("#late_submission_warning").text("Date selected");
}
});
下面是從頁(縮短)HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title> Feedback for Student, Test</title>
<meta name="description" content="">
<link href="/static/css/bootstrap.css" rel="stylesheet" media="screen">
<link href="/static/css/jquery.qtip.min.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
.sidebar-nav{
padding: 9px 0;
}
</style>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
...
</nav>
<form action="" method="post" accept-charset="utf-8" role="form">
<input type='hidden' name='csrfmiddlewaretoken' value='...' />
<div class="container">
<h1>European Law (2013/2014): Essay</h1>
<h2>Test Student</h2>
...
<label for="submission_date">Submission Date</label>
<input class="form-control" data-date-format="dd/mm/yyyy" id="id_submission_date" name="submission_date" type="text" value="13/04/2015" />
<select class="form-control" id="id_category_mark_2" name="category_mark_2">
<option value="" selected="selected">---------</option>
<option value="39">0 - 39 %</option>
<option value="49">40 - 49 %</option>
<option value="59">50 - 59 %</option>
<option value="69">60 - 69 %</option>
<option value="79">70 - 79 %</option>
<option value="80">80 or more</option>
</select>
<div id="late_submission_warning"></div>
<h4>General Comments</h4>
<textarea class="form-control" cols="40" id="id_comments" name="comments" rows="10">
</textarea>
<br><br>
<input type = "submit" value="Save" class="btn btn-default">
</form>
</div>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.js"></script>
<script src="/static/js/bootstrap-datepicker.js"></script>
<script src="/static/js/jquery.tablesorter.js"></script>
<script src="/static/js/jquery.metadata.js"></script>
<script src="/static/js/jquery.validate.min.js"></script>
<script src="/static/js/bootbox.min.js"></script>
<script src="/static/js/jquery.qtip.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#sortable_table").tablesorter({
sortList: [[0,0],[1,0]]
});
}
);
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#id_submission_date").datepicker({
onSelect: function(dateText) {
console.log(dateText);
}
});
$("#category_2").qtip({
content: {
text: '80+ very full and perceptive awareness of issues, with original critical and analytical assessment of the issues and an excellent grasp of their wider significance.<br />70+ full and perceptive awareness of issues and a clear grasp of their wider significance.<br />60 - 69 adequate awareness of issues and a serious understanding of their wider significance.<br />50 - 59 some awareness of issues and their wider significance.<br />40 - 49 limited awareness of issues and their wider significance.<br />Below 40 very limited awareness of issues and of their wider significance.'
}
});
});
</script>
</body>
</html>
請發佈html以及 –