#jquery #calendar
#jquery #Календарь
Вопрос:
Я пытаюсь реализовать jquery dateticker, но он не работает в соответствии со следующим руководством:
https://designmodo.com/calendar-jquery-css3/
В этом руководстве говорится, что я должен иметь возможность задавать текст, отображаемый для дней недели, с помощью поля dayNamesMin:
$('#calendar').datepicker({
inline: true,
firstDay: 1,
showOtherMonths: true,
dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
});
Но, похоже, это не работает для меня.
Я настраиваю div для календаря следующим образом:
<div class="calendar" id="aug-calendar"></div>
И я инициализирую календарь следующим образом:
$('#aug-calendar').datepicker({
showOtherMonths: false,
dayNamesMin: ['S', 'M', 'T', 'W', 'T', 'F', 'S']
});
На всякий случай, если вам нужно это увидеть, вот класс calendar:
.calendar {
color: white;
font-weight: bold;
}
Но вот как выглядит календарь:
Названия дней по-прежнему отображаются как Su, Mo, Tu…
Кто-нибудь может объяснить, почему dayNamesMin не работает?
ОБНОВЛЕНИЕ: вот ссылка на текущую страницу:
http://hollandandbarnes.azurewebsites.net/entertainment/upcoming-events/
…и полный код для страницы:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = "Master.cshtml";
}
@* the fun starts here *@
<div>
<div class="logo-and-title-container">
<div class="logo-container">
<img src="~/assets/img/logo for upcoming events - 1893x293.png" alt="Holland amp; Barnes.com" width="500px" />
</div>
<div class="upcoming-events-title-container">
<span class="upcoming-events-title">Upcoming Events Search</span>
</div>
</div>
<div class="search-container">
<div class="search-textbox-outer-container">
<div class="search-textbox-inner-container">
<input type="text" class="search-textbox">
</div>
</div>
<div class="search-category-checkbox-group-container">
<div class="search-category-checkbox-row">
<div class="search-category-checkbox-container">
<input type="checkbox">amp;nbsp;Annual Festival
</div>
<div class="search-category-checkbox-container">
<input type="checkbox">amp;nbsp;Concerts
</div>
<div class="search-category-checkbox-container">
<input type="checkbox">amp;nbsp;Conventions
</div>
<div class="search-category-checkbox-container">
<input type="checkbox">amp;nbsp;Cultural Events
</div>
<div class="search-category-checkbox-container">
<input type="checkbox">amp;nbsp;Speakers
</div>
<div class="search-category-checkbox-container">
<input type="checkbox">amp;nbsp;Education
</div>
</div>
<div class="search-category-checkbox-row">
<div class="search-category-checkbox-container">
<input type="checkbox">amp;nbsp;Sporting Events
</div>
<div class="search-category-checkbox-container">
<input type="checkbox">amp;nbsp;Trade Shows
</div>
<div class="search-category-checkbox-container">
<input type="checkbox">amp;nbsp;Live Theatre
</div>
<div class="search-category-checkbox-container">
<input type="checkbox">amp;nbsp;Fashion
</div>
<div class="search-category-checkbox-container">
<input type="checkbox">amp;nbsp;Business
</div>
<div class="search-category-checkbox-container">
<input type="checkbox">amp;nbsp;Arts
</div>
</div>
</div>
</div>
<div class="main-content-container">
<div class="calendar-container">
<div class="calendar" id="aug-calendar"></div>
<div class="calendar" id="sep-calendar"></div>
<div class="calendar" id="oct-calendar"></div>
<div class="calendar" id="nov-calendar"></div>
</div>
<div class="buttons-and-events-container">
</div>
</div>
</div>
@section Styles {
<style>
.search-category-checkbox-container {
width: 150px;
}
.search-category-checkbox-row {
width: 90%;
height: 20px;
display: flex;
flex-direction: row;
justify-content: space-between;
margin: 5px 0;
}
.search-category-checkbox-group-container {
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-bottom: 20px;
color: black;
font-family: Futura;
font-size: 20px;
}
.search-textbox {
width: 95%;
border: none;
height: 46px;
font-size: 25px;
padding-left: 10px;
}
.search-textbox-inner-container {
border: black solid 2px;
width: 100%;
margin: 30px 40px;
height: 50px;
background: url('/assets/img/search icon.png') no-repeat;
background-position: right;
background-origin: content-box;
padding-right: 5px;
box-shadow: 8px 8px 10px #aaaaaa;
}
.search-textbox-outer-container {
width: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.search-container {
background-color: white;
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
}
.upcoming-events-title {
font-size: 50px;
color: white;
}
.upcoming-events-title-container {
width: 60%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.logo-container {
width: 40%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
min-width: 550px;
}
.logo-and-title-container {
background-color: rgb(35,31,32);
width: 100%;
height: 200px;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.calendar {
color: white;
font-weight: bold;
padding: 10px;
}
.ui-datepicker {
font-family: Futura;
}
/*.next, .prev {
display: none;
}*/
/*
.table-condensed thead tr:first-child .datepicker-switch {
width: 100% !important;
margin: auto !important;
background-color: red;
}*/
.main-content-container {
width: 100%;
display: flex;
flex-direction: row;
justify-content: flex-start;
}
.calendar-container {
display: flex;
flex-direction: column;
justify-content: center;
background-color: rgb(65,64,66);
width: 300px;
align-items: center;
padding: 10px 0;
}
.buttons-and-events-container {
display: flex;
flex-direction: column;
justify-content: center;
background-color: rgb(230,231,232);
flex-grow: 1;
}
@@font-face {
font-family: "Futura";
src: url("assets/fonts/Futura.ttf") format("TrueType"),
}
</style>
}
@section Scripts {
<script>
$(function () {
for (let month of ['aug', 'sep', 'oct', 'nov']) {
$('#' month '-calendar').datepicker({
showOtherMonths: false,
dayNamesMin: ['S', 'M', 'T', 'W', 'T', 'F', 'S']
});
}
//$('#aug-calendar thead tr:first-child').addClass('green-background');
//$('#aug-calendar thead tr:first-child').css('width', '100%');
//$('#aug-calendar thead tr:first-child').html('<th class="red-background" style="width: 100%;">August</th>');
});
</script>
}
Комментарии:
1. какую версию jQuery UI datepicker вы используете? Приведенный выше календарь не похож на jQuery UI datepicker. Пожалуйста, уточните, хотите ли вы, чтобы кто-нибудь объяснил, почему dayNamesMin не работает!!!
2. В файле jquery-ui.css, который у меня есть в моем проекте, написано «jQuery UI — v1.12.1 — 2016-09-14». То же самое с jquery-ui.js .
3. Можете ли вы привести минимальный пример, в котором можно увидеть эту проблему — например, демонстрацию js fiddle ?
4. Да, я обновил OP ссылкой на текущую страницу плюс код для этой страницы.