我有一个简单的模式在我的看法与日期选择器输入字段。我遵循堆栈溢出中的一些指令,但是我仍然无法工作,我不知道为什么。Datepicker将不会在引导模式下打开
这里是脚本的一部分,从我的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' :) –