Thursday, January 17, 2013

Overlay calendar items open in new window instead in Modal Popup

When you create overlay calendar view for combined 2 or 3 views especially for colour coded calendar, if you create event with category and click on it, it will open in popup which is by default function of SharePoint.
If you create event without category column value and click on it, it will open in new window. To remove the above problem use the below javascript.

<script src="/sites/CUEDemo/Code%20Library/jquery-1.8.3.min.js" type="text/javascript"></script>

<script type="text/javascript">
// load our function to the delayed load list
                _spBodyOnLoadFunctionNames.push('calendarEventLinkIntercept');

                // hook into the existing SharePoint calendar load function.
                function calendarEventLinkIntercept()
                {
                                if (SP.UI.ApplicationPages.CalendarNotify.$4a)
                                                {
                                                var OldCalendarNotify = SP.UI.ApplicationPages.CalendarNotify.$4a;
                                                SP.UI.ApplicationPages.CalendarNotify.$4a = function ()
                                                {
                                                OldCalendarNotify();
                                                bindEventClickHandler();
                                                }
                                                }
                                if (SP.UI.ApplicationPages.CalendarNotify.$4b)
                                                {
                                                var OldCalendarNotify = SP.UI.ApplicationPages.CalendarNotify.$4b;
                                                SP.UI.ApplicationPages.CalendarNotify.$4b =  function ()
                                                {
                                                OldCalendarNotify();
                                                bindEventClickHandler();

                                                } 
                                }
                  // future service pack change may go here!
                  // if (SP.UI.ApplicationPages.CalendarNotify.???)
                }

                function bindEventClickHandler()             {
                                $('.ms-acal-rootdiv a').click(function(){EditLink2(this,'WPQ2');return false;});
                }



</script>

1 comment:

  1. I have very similar code, I wonder if we referenced the same source ;). I recently updated mine to include day and week views as well: http://davidlozzi.com/2013/02/06/calendar-overlays-keeping-events-in-the-same-window/

    ReplyDelete