У меня есть простой модальный вид с полем ввода datepicker. Я выполнил некоторые инструкции из ответов в переполнении стека, но то, что у меня все еще не работает, и я не знаю, почему.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' :) –