I need to only show month and year when a user selects the datepicker. I have followed examples and tried to find a problem but it just seems to not be working. Can some one please help? cshtml file
<div class=" accordion" id="accordion">
<i class="icon-plus-sign app-icon-orange icon-2x" style="cursor:pointer" id="btnAddTierGroup"></i> Add new date range
@*Create a panel for each time period*@
@for (var i = 0; i < Model.Periods.Count; i++)
{ @Html.EditorFor(x => x.Periods[i], "TimePeriodTiers") }
</div>
JS (minViewMode: 1 is months for those unfamiliar with bootstrap)
$(document).ready(function () {
$('[id^="Periods"]').datepicker({
format: "mm/dd/yyyy",
minViewMode: 1
});
})
EDIT: I found I had two problems. One fixed and one still exists. 1. the selector id^="Periods" was attaching to too many objects. Fixed by using 'id$=BeginDate' so it only grabs what I need it to. 2. there is a function in the JS that stop the user from selecting past the end date of other Tiers. the two scenarios are as follows: the function works but allows user to pick back dates
<script type="text/javascript">
var MaxTierCount = 25;
var MaxRate = @ViewBag.RateNotification
SetUpTableSorter();
$('[id$=BeginDate]').ready(function () {
$('[id$=BeginDate]').datepicker({
format: "mm/dd/yyyy",
startView: "months",
minViewMode: 1
});
})
setupDateRanges($('#accordion'));
Scenario 2: user is unable to pick back dates but the function does not work:
<script type="text/javascript">
var MaxTierCount = 25;
var MaxRate = @ViewBag.RateNotification
SetUpTableSorter();
setupDateRanges($('#accordion'));
$('[id$=BeginDate]').ready(function () {
$('[id$=BeginDate]').datepicker({
format: "mm/dd/yyyy",
startView: "months",
minViewMode: 1
});
})
Any help?