我正在尝试在点击时对其进行样式折叠切换,并期望在显示折叠时存在切换类。但是bootstrap4中的实际逻辑,例如:
<button data-toggle="collapse">Button</button>
<div class="collapse">Collapse Content</div>
collapsed
添加到按钮切换。collapsed
将从按钮切换中删除。如果在展示合作内容时,如何将按钮切换为不同的样式?
答案 0 :(得分:0)
http://getbootstrap.com/docs/4.1/components/collapse/
foreach (Schedule schedule in db.Schedules.Where(s => s.ReportID == this.ReportID))
{
ScheduleViewModel svm = this.Schedules.FirstOrDefault(s => s.ScheduleID == schedule.ScheduleID);
//Update Existing
if (svm != null)
db.Entry(schedule).CurrentValues.SetValues(svm);
//Delete Missing
else
db.Entry(schedule).State = System.Data.Entity.EntityState.Deleted;
}
//Insert New
foreach(ScheduleViewModel svm in this.Schedules.Where(s => s.ScheduleID == 0))
{
svm.ReportID = ReportID;
Schedule schedule = new Schedule() {};
db.Schedules.Add(schedule);
db.Entry(schedule).CurrentValues.SetValues(svm);
}
$(document).ready(function(){
$('#collapseExample').on('hide.bs.collapse', function () {
$('#myBtn').removeClass('btn-success');
$('#myBtn').addClass('btn-primary');
});
$('#collapseExample').on('show.bs.collapse ', function () {
$('#myBtn').removeClass('btn-primary');
$('#myBtn').addClass('btn-success');
})
});