Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FullCalendar open bootstrap modal on dayClick

I want to open a bootstrap modal when users click on a day in fullCalendar. I have look over dayClick event but can't figure out how to call the model.

dayClick: function(date, jsEvent, view) {
     // call the model 
},

Normal link to call a bootstrap model

<a href="#" data-toggle="modal" data-target="#myModal"..................../>

EDIT :

I use only 1 bootstrap model for all my needs and simply change the content. The way I do this is by calling a href .. so my link looks like :

<a href="<?php echo site_url('model/add') ?>" data-toggle="modal" data-target="#myModal" role="button" class="btn-u btn-block"> Add</a>
like image 663
George Avatar asked Mar 16 '15 08:03

George


3 Answers

If someone else needs to open fullCalendar events in bootstrap model I found the way to do it :

Add :

        eventClick:  function(event, jsEvent, view) {
            $('#modalTitle').html(event.title);
            $('#modalBody').html(event.description);
            $('#eventUrl').attr('href',event.url);
            $('#calendarModal').modal();
        },

And the model :

<div id="calendarModal" class="modal fade">
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span> <span class="sr-only">close</span></button>
            <h4 id="modalTitle" class="modal-title"></h4>
        </div>
        <div id="modalBody" class="modal-body"> </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
    </div>
</div>
</div>
like image 127
George Avatar answered Nov 09 '22 23:11

George


The following should work:

dayClick: function(date, jsEvent, view) {
    $("#myModal").modal("show");
},

Assuming that the ID of your modal is in fact myModal. .modal() is the JavaScript method used by bootstrap to manipulate modals... Similarly, you can close the modal using $("#myModal").modal("hide")...

like image 39
Amina Avatar answered Nov 10 '22 01:11

Amina


Another way is upon calendar redering:

eventRender: function(event, element) {
                        element.attr('data-toggle', "modal");
                        element.attr('data-target', "#sched-modal");
                        element.attr('href', "/details");
                    }
like image 26
h3n Avatar answered Nov 10 '22 00:11

h3n