简体   繁体   中英

fullcalendar bootstrap modal with external event data

I'm using full calendar with a asp.net MVC 5 application.

When I click a on a empty space I get a modal view for creating a event. This works perfect.

When I click on a event I want to get the event data but also some other data then just the start date end date and description.

I have the following:

eventRender: function (event, element) {
                var id = event.id;
                element.popover({
                    placement: 'top',
                    html: true,
                    content: '<button id="customers" class="btn btn-default" onclick="KlantenModal(' + id + ')">Klant overzicht</button>',
                    animation: true
                });
            }

The function that calls the modal.

function KlantenModal(event) {
        $('#klanten #eventId').val(event);
        $('#klanten').modal('show');
    }

and the bootstrap modal:

<div class="modal fade" id="klanten" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
    <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Klanten</h4>
            </div>
            <div class="modal-body">

               /* here I want some Data eg. names of customers */

                 <input type="hidden" id="eventId" name="eventId" />


            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                <button type="submit" class="btn btn-primary"></button>
            </div>

    </div>
</div>

If i understood you well the only thing you have to do is to add fields to the event like this:

Somewhere in your code populate an array with diferent customers and add that array to the event properties

    var customers = [];
    customers.push("im customer x");
    customers.push("im customer y");
    ...
events:[ 
        {
         'start': 2013-12-30,
         'end': 2013-12-30,
         'allDay': true,
         'customers': customers
        }

and when you click on the event and access the event fields you will get the customers field wich contains your customers for that day.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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