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.
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!
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.
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.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With