SharePoint 2013 Overlay Events to be Opened on Popup

Standard

 Yesterday we got a customer request that asked us to make all events on SharePoint calendar list to be opened on popup instead of open it on a new page

 We simply go to list setting and change dialog setting from list’s advanced settings. However this is doesn’t work for overlay events and continued to open it on a new tab

 We found a lot of solution using java-script on the internet, but none of them has worked for us.

 After we mixed some solutions we make the following code to solve this problem:

Note: You must include JQuery library to your code.

//Open popup function
function openDialog(pUrl) {
     var options = {
          title : "Calendar",
          width : 600,
          height : 400,
          url : pUrl
         };
     SP.SOD.execute("sp.ui.dialog.js", "SP.UI.ModalDialog.showModalDialog", options);
}

//Change the displayed events to open in a popup
$(document).ready(function(){
     setTimeout(function(){
         $(function(){
              $(".ms-acal-rootdiv a").each(function (){
              var parent =            $(this).parent().parent();
              var url = $(this).attr("href");
              $(this).removeAttr("target");
              $(this).replaceWith(function(){
               return $("<span>" + $(this).html() + "</span>");
           });

           parent.click(function (){
           openDialog(url);
        });
      });
     });
   } ,1000);
});
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s