【问题标题】:Get data from jQuery Fullcalendar and pass it to controller从 jQuery Fullcalendar 获取数据并将其传递给控制器
【发布时间】:2014-12-16 06:22:42
【问题描述】:

当点击它时,我需要获取所选事件的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>

【问题讨论】:

  • 对不起,你要什么链接? :(
  • @AfghanWiz 哦,你的意思是 eventlink?该链接似乎不起作用,当我单击 Accomplish Appointment 按钮时,它只是重定向到 = form_open('home/accomplish_appointment');?>跨度>
  • 请帮忙,我是 jquery 新手
  • @AfghanWiz 如果你要一个测试链接,我没有它:(
  • 好的,您是否已经拥有您在此处所述的 eventid:$("#eventrefid").html(event.id);

标签: javascript jquery codeigniter fullcalendar


【解决方案1】:

尝试使用下面的代码传递 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();?>

【讨论】:

  • 你好,我刚回来,谢谢你的快速回复,我现在就试试。
  • 感谢@AfghanWiz 的帮助。我很感激。我希望你能帮助我解决关于从数据库中获取值到数据表(不是 ignitedDatatables)的新查询)
猜你喜欢
  • 2017-12-23
  • 2015-08-23
  • 2023-03-14
  • 2021-04-27
  • 2021-12-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多