从jQuery Fullcalendar获取数据并将其传递给控制器

时间:2014-12-16 06:22:42

标签: javascript jquery codeigniter fullcalendar

我需要在点击时获取所选事件的id的值。打开对话框后,我有一个链接将重定向到另一个页面。我需要将eventid传递给控制器​​,以将其用于重定向页面。

我似乎无法解决这个问题,已经持续了一个星期。

这是我的剧本:

<script type='text/javascript'>
$(document).ready(function(){
    $('#calendar').fullCalendar({
        header : {
            left: 'prev,next',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        allDay: false,
        events: "<?php echo site_url('home/calendarList') ?>",
    eventClick:  function(event, jsEvent, view) {
    //set the values and open the modal
    $("#startTime").html(moment(event.start));
    $("#startTime").html(moment(event.start).format('h:mm A'));
    $("#endTime").html(moment(event.start).add('hours',1).format('h:mm A'));
    $("#eventInfo").html(event.description);
    $("#eventIssue").html(event.issue);
    $("#eventrefid").html(event.id); //i need to pass the value of this 
                                     //to my controller and 
                                     //which will be used in another page
                                     //(no ajax needed if possible)
    $("#eventID").html(event.issue);
    $("#eventLink").attr('href', event.url);
    $("#eventContent").dialog({ modal: true, title: event.title });
    $(this).css('border-color', 'red');
    }
   });
});
</script>

这是我的HTML代码:

<section>

    <div class="content" id="eventContent" title="Event Details" style="display:none;">

        <?= form_open('home/accomplish_appointment');?>

            <span style="font-weight: bold;">From:</span> <span id="startTime"></span><br>

            <span style="font-weight: bold;">To: <span id="endTime"></span>

            <hr>

            <span style="font-weight: bold;">Issue: <span id="eventIssue"></span><br>

            <span style="font-weight: bold;">Special Instruction: <span id="eventInfo"></span><br><br>

            <button class="fr submit small" type="submit" id="eventLink">Accomplish Appointment</button>

        <?= form_close();?>

    </div>

</section>

1 个答案:

答案 0 :(得分:0)

尝试使用下面的代码传递eventid。它将提交eventid的表单提交给home/accomplish_appointment

在jquery代码中添加此项以将事件id分配给表单的隐藏输入:

$("#eventID").val($("#eventrefid").html(event.id));

并在html中:

<?= form_open('home/accomplish_appointment');?>
<input type="hidden" id="eventID" name="eventid" />
<span style="font-weight: bold;">From:</span> <span id="startTime"></span><br>
<span style="font-weight: bold;">To: <span id="endTime"></span>
<hr>
<span style="font-weight: bold;">Issue: <span id="eventIssue"></span><br>
<span style="font-weight: bold;">Special Instruction: <span id="eventInfo"></span><br><br>
<button class="fr submit small" type="submit" id="eventLink">Accomplish Appointment</button>
<?= form_close();?>