【发布时间】:2020-04-09 19:10:31
【问题描述】:
我正在尝试在用户单击“预订”按钮时更改事件的颜色。 默认情况下,按钮设置为绿色,但希望它在单击时变为橙色。
$(' #eventBook').click(function () {
var json = {
'Id': $('#eventBookId').val(),
'Title': $('#eventBookTitle').val(),
'Start': $('#eventBookStart').val(),
'End': $('#eventBookEnd').val(),
'AllDay': $('#eventBookAllDay').is(":checked") ? true : false,
'Description': $('#eventBookDescription').val(),
'Color': "Orange"//$('#eventBookColor').val()
};
console.log('Updating event json', json);
$.ajax({
type: "POST",
url: '/TimeTable/BookEvent',
data: json,
dataType: 'json',
success: function (data) {
//refresh the calender
FetchEventsAndRenderCalendar();
},
error: function () {
alert('Booking Could not be Saved');
}
});
// close Modal
$('#eventModal').modal('hide');
});
这是我在数据库中更新类的服务方法。
public bool BookEvent(TimeTableEvent t)
{
var existing = db.TimeTableEvents.Where(a => a.Id == t.Id).FirstOrDefault();
if (existing != null)
{
existing.Title = t.Title;
existing.Start = t.Start;
existing.End = t.End;
existing.Description = t.Description;
existing.Color = "Orange";
existing.AllDay = t.AllDay;
db.SaveChanges();
return true;
}
return false;
}
任何帮助将不胜感激。
【问题讨论】:
标签: c# html asp.net .net-core asp.net-ajax