我正在渲染不同的日期,我還沒有報告過。asp.net/jQuery選擇所有隻在標籤內工作
如果時間跨度超過1個月,它會渲染出每個月和右側選項卡下的日期。如果日期僅在1個月內,它只會渲染日期。
但我的問題是當日期不在標籤下我的「選擇」所有複選框不起作用。
這是我的腳本:
$(function() {
$(".selectAll").on("click", function() {
if ($(this).is(':checked')) {
$(this).closest('.panel-default').find("input[name='isoDate']").prop('checked', this.checked);
$('input[name="isoDate"]').trigger('change');
} else {
$(this).closest('.panel-default').find("input[name='isoDate']").prop('checked', false);
$('input[name="isoDate"]').trigger('change');
}
});
});
而且本所認爲:
@if (ViewBag.MissingDays != null)
{
int i = 0;
var months = ((List<DateTime>)ViewBag.MissingDays).GroupBy(x => x.Month);
IEnumerable<IGrouping<int, DateTime>> groups = months as IList<IGrouping<int, DateTime>> ?? months.ToList();
foreach (var group in groups)
{
i++;
var month = CultureInfo.CreateSpecificCulture("sv-SE").DateTimeFormat.GetMonthName(group.Key);
if (groups.Count() > 1)
{
<div class="panel-group accordion" id="accordion1">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion1" href="#[email protected]">
@month
</a>
</h4>
</div>
<div id="[email protected]" class="panel-collapse collapse">
<div class="panel-body">
<div class="col-md-12">
<label>
<input type="checkbox" class="selectAll" name="all"/>
Välj alla.
</label>
<br/>
@foreach (var date in group)
{
var isoDate = date.ToString("yyMMdd");
var day = date.ToString("ddd", new CultureInfo("sv-SE")).Substring(0, 2);
<label style="padding-left: 10px">
<input type="checkbox" class="selectedId" name="isoDate" value="@isoDate"/>@[email protected]
</label>
}
</div>
</div>
</div>
</div>
</div>
}
else
{
<div class="col-md-12">
<label>
<input type="checkbox" class="selectAll" name="all" />
Välj alla.
</label>
@foreach (var date in group)
{
var isoDate = date.ToString("yyMMdd");
var day = date.ToString("ddd", new CultureInfo("sv-SE")).Substring(0, 2);
<label style="padding-left: 10px">
<input type="checkbox" class="selectedId" name="isoDate" value="@isoDate" />@[email protected]
</label>
}
</div>
}
}
}
你想添加你的屏幕形象? – Lali