简体   繁体   English

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

[英]Get data from jQuery Fullcalendar and pass it to controller

I need to get the value of the id of the event chosen, when it's clicked. 单击时,我需要获取所选事件的id的值。 Once the dialog box is open, I have a link that will redirect to another page. 打开对话框后,我将获得一个链接,该链接将重定向到另一个页面。 I need to pass the eventid to the controller to use it to the redirected page. 我需要将eventid传递给控制器​​,以将其用于重定向的页面。

I can't seem to resolve this issue, got it going for a week already. 我似乎无法解决此问题,已经解决了一个星期。

Here's my script: 这是我的脚本:

<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>

And here is my HTML code: 这是我的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>

try to pass the eventid using the code bellow. 尝试使用下面的代码传递eventid。 It submits the form which sends the eventid to home/accomplish_appointment : 它提交将eventid发送到home/accomplish_appointment的表单:

in jquery code add this to assign the event id to the hidden input of the form: 在jquery代码中,添加以下代码可将事件ID分配给表单的隐藏输入:

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

and in the html: 并在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();?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM