Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
315 views
in Technique[技术] by (71.8m points)

javascript - Use Bootstrap Modal on Fullcalendar js

I have a question, I am having a hard time to figure out a way to use bootstrap modal in fullcalendar. What I am trying to do is when you click on the event on the calendar, the modal will pop-up and provide the full name of the event and summary of the event.

The following is the code I am using to generate the calendar:

<cffunction name="FullCalendar">

    <cfscript>

        var calendarid = $.getbean('content').loadby(title='Regal Events').getcontentid();


    </cfscript>
    <cfsavecontent variable="local.str">
        <cfoutput>           

                 <div id="UpcomingCal" class="calendarResize">
                 </div>
                 <div id="fullCalModal" 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>
                                <button class="btn btn-primary"><a id="eventUrl" target="_blank">Event Page</a></button>
                            </div>
                        </div>
                    </div>
                </div>
         <script>

         mura.loader()
            .loadcss("#$.siteConfig('requirementspath')#/fullcalendar/fullcalendar.css",{media:'all'})
            .loadcss("#$.siteConfig('requirementspath')#/fullcalendar/fullcalendar-custom.css",{media:'all'})
            .loadcss("#$.siteConfig('requirementspath')#/fullcalendar/fullcalendar.print.css",{media:'print'})
            .loadjs(
                "#$.siteConfig('requirementspath')#/fullcalendar/lib/moment.min.js",
                "#$.siteConfig('requirementspath')#/fullcalendar/fullcalendar.min.js",
                "#$.siteConfig('requirementspath')#/fullcalendar/gcal.js",
                function(){
                     $('##UpcomingCal').fullCalendar({
                         weekMode: 'variable',
                         eventSources: [
                            {
                                $('#eventUrl'): '#variables.$.siteConfig('requirementspath')#/fullcalendar/proxy.cfc?calendarid=#esapiEncode("javascript",CalendarID)#'
                                , type: 'POST'
                                , data: {
                                    method: 'getFullCalendarItems'
                                    , calendarid: '#esapiEncode("javascript",CalendarID)#'
                                    , siteid: '#variables.$.content('siteid')#'
                                    , categoryid: '#esapiEncode('javascript',variables.$.event('categoryid'))#'
                                    , tag: '#esapiEncode('javascript',variables.$.event('tag'))#'
                                }
                                <!---, color: '#this.calendarcolors[colorIndex].background#'
                                , textColor: '#this.calendarcolors[colorIndex].text#'--->
                                , error: function() {
                                    $('##mura-calendar-error').show();
                                }
                            },
                        ]
                    });
                }
               )
         </script>

        </cfoutput>
    </cfsavecontent>
    <cfreturn local.str />
</cffunction>

As you can see above, I have included the bootstrap modal. However, I am not sure how to add the following code so that when you click on the event, the modal appears:

$(document).ready(function() { 
$('#bootstrapModalFullCalendar').fullCalendar({
    events: '/hackyjson/cal/',
    header: {
        left: '',
        center: 'prev title next',
        right: ''
    },
    eventClick:  function(event, jsEvent, view) {
        $('#modalTitle').html(event.title);
        $('#modalBody').html(event.description);
        $('#eventUrl').attr('href',event.url);
        $('#fullCalModal').modal();
    }
});

});

Any help would be appreciated

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your problem is not is not related to javascript, bootstrap or fullcalendar.

I created a minimal test case to help you out and it works.

You should check coldfusion and mura.loader code.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...