-1

hello i want to check if color has color css('#FF7F50') : show an alert message i try but no succes can i find someone help

        function GenerateCalender(events) {
            $('#calender').fullCalendar('destroy');
            $('#calender').fullCalendar({
                contentHeight: 400,
                defaultDate: new Date(),
                timeFormat: 'h(:mm)a',
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,basicWeek,basicDay,agenda'
                },
                eventLimit: true,
                eventColor: '#FF7F50',

                events: events,

this my function

                /******Check Color *******/
                eventClick: function (calEvent, jsEvent, view) {
                    if (calEvent.eventColor == "#FF7F50") {
                      return  alert("tttt");
                    }

this my controller :

  public JsonResult Check(string ThemeColor)
    {
        return Json(db.Events.Any(c => c.ThemeColor == "NULL"));
    }

this my scripts :

     eventClick: function (calEvent, jsEvent, view) {

                    //return $.ajax({
                    //    type: "POST",
                    //    url: "/Home/Check",
                    //    data: "ThemeColor",

                    //    contentType: "application/json; charset=utf-8",
                    //    dataType: "json",
                    //    success: function (response) {
                    //        if (response) {
                    //            alert("tttt");

                    //        }
                    //        else {
                    //            alert("tttt222222");


                    //        }

                    //    }


                    //});

how i can call the eventcolor to chec if color is NULL or not

1 Answers1

0

There's no such property as eventColor on an event. The list of recognised properties, including colour ones, is here: https://fullcalendar.io/docs/v3/event-object .

It seems you confused it with eventColor which is a global option you can set on the whole calendar, not a specific event.

As per that documentation. the equivalent property on an event object is color, so you can amend your code as follows and it should work:

eventClick: function (calEvent, jsEvent, view) {
  if (calEvent.color == "#FF7F50") {
    return  alert("tttt");
  }

P.S. return alert doesn't make much sense - an alert doesn't generate a value to be returned. I think you can simplify it to just alert("tttt");. Returning a value from eventClick wouldn't have any purpose anyway - fullCalendar isn't expecting the callback to provide any kind of response.

ADyson
  • 57,178
  • 14
  • 51
  • 63
  • thank you very much but your solutions work but i have database and when the color is NULL and color in view example red the function not workk for me – Afifa Ameur Jun 04 '20 at 12:45
  • so i added a function ajax to check if color is NULL or not but i don't know what i write in calEvent – Afifa Ameur Jun 04 '20 at 12:47
  • i edit my post to understand me if color have NULL in database alert me message if not show me the other alert – Afifa Ameur Jun 04 '20 at 12:50
  • sorry I don't understand why you need to check in the database whether any events have a null colour or not? That part does not make sense to me. Please explain more clearly what your goal is. – ADyson Jun 04 '20 at 13:59