简体   繁体   English

从Fullcalendar事件click进行Bootstrap模态调用

[英]Bootstrap modal call from fullcalendar event click

I have a fullcalendar on my page. 我的页面上有一个日历。 On it I have an add event button. 在它上面有一个添加事件按钮。 That calls a javascript function that opens a modal view allowing the user to add an event. 那将调用一个javascript函数,该函数打开一个模式视图,允许用户添加事件。

function showAddMeeting() {
    var current_date = $('#calendar').fullCalendar('getDate');
    $("#modal").load('modal.php?type=meeting&action=add&date='+current_date);
}

This works perfectly. 这很完美。 Now, I have another function to edit the meeting: 现在,我还有另一个功能可以编辑会议:

function showEditMeeting(meeting_id) {
    alert('modal.php?type=meeting&action=edit&id='+meeting_id);
    $("#modal").load('modal.php?type=meeting&action=edit&id='+meeting_id);
}

When I put this on the button, it works fine. 当我将其放在按钮上时,它可以正常工作。 But when I add it as a function to the event, it does not work. 但是,当我将其添加为事件的功能时,它将无法正常工作。

eventClick: function(event) {
    showEditMeeting(event['id']);
}

When I click the event, I get the alert of the working link, but I never get a modal popover. 当我单击该事件时,会收到工作链接的警报,但从未收到模式弹出窗口。

EDIT: 编辑:

I've figured out it's because I'm not calling 我发现这是因为我没有打电话

 data-toggle="modal" data-target="#modal"

Does anybody know of how to call that through javascript? 有人知道如何通过javascript调用它吗?

Bootstrap has all the methods available for the modal in "modal.js", this is included in the minified pack. Bootstrap在“ modal.js”中提供了可用于模式的所有方法,该方法包含在最小化包中。

You need to use it as follows. 您需要按以下方式使用它。

Original 原版的

function showEditMeeting(meeting_id) {
    alert('modal.php?type=meeting&action=edit&id='+meeting_id);
    $("#modal").load('modal.php?type=meeting&action=edit&id='+meeting_id);
}

Becomes

function showEditMeeting(meeting_id) {
    alert('modal.php?type=meeting&action=edit&id='+meeting_id);
    $("#modal").load('modal.php?type=meeting&action=edit&id='+meeting_id).modal('show');
}

Notice the additional .modal('show'); 注意附加的.modal('show');

Please note, I've not tested this code. 请注意,我尚未测试此代码。

More information: http://getbootstrap.com/javascript/#modals-methods 详细信息: http : //getbootstrap.com/javascript/#modals-methods

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

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