单击全日历上的 "book" 按钮时如何更改事件的颜色
How to change colour of event when click "book" button on fullcalendar
我正在尝试更改用户单击 "book" 按钮时事件的颜色。
默认情况下,按钮设置为绿色,但希望在单击时将其更改为橙色。
$(' #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');
});
这是我在数据库中更新 class 的服务方法。
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;
}
如有任何帮助,我们将不胜感激。
使用以下内容:
document.getElementById("eventBook").style.color= "orange";
假设您要更改文本颜色。或者 backgroundcolor 如果你想改变背景颜色。
我正在尝试更改用户单击 "book" 按钮时事件的颜色。 默认情况下,按钮设置为绿色,但希望在单击时将其更改为橙色。
$(' #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');
});
这是我在数据库中更新 class 的服务方法。
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;
}
如有任何帮助,我们将不胜感激。
使用以下内容:
document.getElementById("eventBook").style.color= "orange";
假设您要更改文本颜色。或者 backgroundcolor 如果你想改变背景颜色。