【发布时间】:2017-06-14 09:57:49
【问题描述】:
我的视图中有一个带有日期选择器输入字段的简单模式。我按照堆栈溢出答案中的一些说明进行操作,但我仍然无法正常工作,我不知道为什么。
这是我的 asp.net mvc 视图中的脚本部分:
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript">
$('#mdl').on('click', function () {
var parent = $(this).closest('.jumbotron');
var name = parent.find('input[name="NAME_OF_MODEL"]').val();
var id = parent.find('input[name="ID_OF_MODEL"]').val();
console.log(id);
//var titleLocation = $('#myModal').find('.modal-body'); modal - title
var titleLocation = $('#myModal').find('.modal-title');
titleLocation.text(name);
// for each information you'll have to do like above...
$('#myModal').modal('show');
});
});
$(function () {
$('.date-picker').datepicker();
})
</script>
这里是模态:
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
<input class='date-picker' />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Save</button>
</div>
</div>
</div>
任何帮助将不胜感激。
【问题讨论】:
-
第一次呈现页面时您的模态是否存在,或者它是动态添加的(例如使用 ajax),在这种情况下您需要在添加插件后附加它
-
不是动态添加的。
-
您的脚本顺序错误 -
jquery然后jquery-ui:) -
还是不行..
-
试试这篇文章的答案。 stackoverflow.com/questions/21059598/…
标签: jquery asp.net-mvc twitter-bootstrap datepicker