Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot read property 'clone' of undefined

I'm using Fullcalendar and I'm trying to update events. I'm trying to make an ajax callback to get def edit of that event. The route would be /controls/:id/edit, so I've built this ajax callback:

eventClick: function(date, jsEvent, view) {
                console.log(date.id)
                console.log(jsEvent)
                console.log(view)
                 $.ajax({
                  type: "GET",
                  url: "/controls/"+date.id+"/edit",
                  });

            $('#calendar').fullCalendar('updateEvent', event);

}

The code of the controls_controller.rb is this:

def edit
    if request.xhr?
        @control = Control.find(params[:id])
    end
end

My problem is that when I click on one event the console tells me "Uncaught TypeError: Cannot read property 'clone' of undefined". I don't know what that means. I think I'm doing it right but it doesn't work. Anyone could help me?? Thank you in advance.

like image 323
David Dsr Avatar asked Dec 07 '14 13:12

David Dsr


People also ask

How to solve cannot read property of undefined error?

To solve the "Cannot read property of undefined" error, make sure to insert the JS script tag at the bottom of the body. The JS script tag should be placed after the HTML elements have been declared. Copied!

What is the meaning of undefined in JavaScript?

Undefined means that a variable has been declared but has not been assigned a value. In JavaScript, properties and functions can only belong to objects. Since undefined is not an object type, calling a function or a property on such a variable causes the TypeError: Cannot read property of undefined.

Why can’t I call a function on an undefined variable?

In JavaScript, properties and functions can only belong to objects. Since undefined is not an object type, calling a function or a property on such a variable causes the TypeError: Cannot read property of undefined.


1 Answers

Please check the event data . Source attribute of your event must be null or not populated. SO before calling

$('#calendar').fullCalendar('updateEvent', event);

You have to be make sure that required attribute of your fullcalendar event must be populated. Here is the link for required and optional fieldfor event object.

http://fullcalendar.io/docs/event_data/Event_Object/

like image 150
Mohit Verma Avatar answered Oct 22 '22 02:10

Mohit Verma