【问题标题】:How to change colour of event when click "book" button on fullcalendar单击全日历上的“预订”按钮时如何更改事件的颜色
【发布时间】: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


    【解决方案1】:

    使用以下内容:

    document.getElementById("eventBook").style.color= "orange";
    

    假设您要更改文本颜色。如果你想改变背景颜色,或者 backgroundcolor。

    【讨论】:

    • 当我在我的 javascript 函数中添加它时,按钮本身的颜色会变为橙色。但是,我想要它,所以如果我单击“预订”按钮,弹出窗口将消失,日历上的事件将颜色变为橙色。关于如何克服这个问题的任何想法?
    • 事件是否有 Id 属性。如果是这样,请使用该属性而不是 eventBook。
    猜你喜欢
    • 2021-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-21
    • 2019-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多