Reputation:
My code is as below.
<script>
var t=<?php echo json_encode($ta)?>;
var d=<?php echo json_encode($da)?>;
$(document).ready(function() {
$('#calendar').fullCalendar({
//defaultDate: '2016-03-12',
editable: true,
eventLimit: true, // allow "more" link when too many events
//$r=$ev->title;
for(var j=0;j<d.length;j++)
{
events: [{
title: t[j],
start: d[j]
}
]
}
});
});
</script>
I have used the fullcalendar 2.6.1. But nothing displayed. Please can anybody help me? I want to retrieve all the title and eventDate from the db and view in the calendar. The var t and d contains the all the data of $ta and $da arrays. I just wanted to assign them to events array title and start keywords.There are some red marks indicate that for loop is going to be wrong.
Upvotes: 1
Views: 159
Reputation: 1465
Try this one
<?php
$ta=array();
$i=0;
?>
@foreach($events as $ev)
<?php
$ta[$i]['title'] = $ev->title;
$ta[$i]['start'] = date('Y-m-d H:i:s', strtotime($ev->eventDate));
$i++;
?>
@endforeach
<script>
var t=<?php echo json_encode($ta)?>;
$(document).ready(function() {
$('#calendar').fullCalendar({
//defaultDate: '2016-03-12',
editable: true,
eventLimit: true, // allow "more" link when too many events
events: t,
eventRender: function(event, element) {
$('.fc-time', element).hide();
}
});
});
</script>
Upvotes: 1
Reputation: 233
$.ajax({ url:'', dataType: 'json', success: function(doc) { var events = []; $.each(doc, function(key, value){ events.push({ title : value['title name'], start : value['hours'], backgroundColor: Metronic.getBrandColor('yellow'), id : value['id'] }); }); AddFullCalenderEvent(events); } }); function AddFullCalenderEvent(eventList){ $('#calendar').fullCalendar({ events: eventList, eventClick: function(event) { // opens events in a popup window window.location.href = "pagename?id=" + event.id; return false; }
Try this
Upvotes: 0