Reputation: 1
I am using full calendar. It is working fine. But I have problem to send parameters by onclick event. I have this js:
<script>
$(document).ready(function() {
$('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: false,
minTime: 8,
maxTime: 21,
weekMode: 'liquid',
eventClick: function(start, end, allDay) { // Get the start, end, allday when one event slot is clicked
$('#time').val(start); // Set an hidden field with start value (String or Timestamp)
$('#hiddenEnd').val(end); // Set another hidden field with end value (String or Timestamp)
$('#hiddenAllDay').val(allDay); // Set another hidden field with allDay value (true or false)
},
events: "<?php echo Yii::app()->request->baseUrl; ?>/index.php/aula/calend/<?php echo $id; ?>",
eventRender: function (event, element) {
element.attr('href', 'javascript:void(0);');
element.attr('onclick', 'openModal("' + event.title + '","' + event.description + '","' + event.start + '");');
},
eventDrop: function(event, delta) {
alert(event.title + ' foi movido ' + delta + ' dia(s)\n' +
'(Esta acao nao altera o banco de dados!)');
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}
});
});
function openModal(title, info, start) {
$("#eventInfo").html(info);
$("#start-time").val(start);
//var dd = start;
$("#add-event").dialog({ modal: true, title: title, width:550,
buttons: {
"Salvar": function() {
$.ajax({
type:"POST",
url: "<?php echo Yii::app()->request->baseUrl; ?>/index.php/aula/marcacao",
data: $('#add-event-form').serialize(),
success: function(){
$('#calendar').fullCalendar('refetchEvents');
}
});
$(this).dialog("close");
},
Cancel: function() {
$(this).dialog("close");
}
},});
};
When I click in one event, I need to send the hour for that event to php, because I need to use it in my query, before open dialog using this form:
<form action="" id ="add-event-form" name="add-event-form">
<?php query = "SELECT aula FROM cursos WHERE hour = ****Hour clicked on calendar**** ?>
<label for="title">Event Name</label>
<input type="text" name="title" id="title"/>
<p>
<label for="add-date">Date</label>
<input type="text" name="event-date" id="event-date" tabindex="-1" />
</p>
<p>
<label for="add-start-time">Start Time</label>
<input type="text" name="start-time" id="start-time" value=""/>
</p>
<p>
<label for="add-end-time">End Time</label>
<input type="text" name="end-time" id="end-time" />
</p>
</form>
I have been trying to solve this for several days without success. Can anyone help me please?
Upvotes: 0
Views: 2514
Reputation: 1519
Instead of eventClick: function(start, end, allDay)
, use eventClick: function(event)
.
Then to access the variables use event.start, event.end, event.allDay. All you need to do then is match them with your query.
This is because eventClick does not take a start, end or allDay parameter but rather an event, jsEvent or view parameters. Source: Official Documentation
Upvotes: 1
Reputation: 1142
Just use $_POST['start-time'] on the server side to retrieve the parameter.
$start = htmlspecialchars($_POST['start-time']);
$query = "SELECT aula FROM cursos WHERE hour =". $start;
Upvotes: 0