We are using O365/Sharepoint Online 2013.
We are using the Sharepoint Calendar as a lightweight general event reminder. We would like to have items opening in a modal dialog instead of a new page. I have turned on the dialogs in the calendar's advanced settings but it didn't help.
I searched the internet for a few days and came up with different scripts to achieve this. The best sources I have found are these:
- How to open a calendar item in a modal dialog?
- http://social.msdn.microsoft.com/Forums/sharepoint/en-US/87634b39-55c3-477a-a58d-c1469f15a9a1/calendar-overlay-how-to-open-in-modal-mode-instead-of-new-window?forum=sharepointdevelopment
- http://social.technet.microsoft.com/wiki/contents/articles/19185.sharepoint-2013-how-to-open-list-forms-in-dialog-box-instead-of-navigating-to-another-page.aspx
The script we have at the moment:
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.1.js"></script>
<script type="text/javascript">
function openDialogBox(Url)
{
var ModalDialogOptions = { url:Url, width: 600, height: 500, showClose: true, allowMaximize: true};
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', ModalDialogOptions);
}
$('.ms-acal-month').ready(function () {
setTimeout(function() {
$('a[href*="DispForm.aspx"]').each(function() {
$(this).attr('onclick', 'openDialogBox("' + $(this).attr('href') + '")');
//$(this).attr('onclick', ' ');
//alert($(this).attr('href'));
});
$('a[href*="DispForm.aspx"]').each(function() {
$(this).attr('href','javascript:openDialogBox("' + $(this).attr('href') + '")');
});
}, 3000);
});
</script>
This script is working fine for the monthly view when clicking an event in the current month but if we user the arrows to show the next month, events are not opening in a modal dialog anymore.
What's wrong? How to fix it? I'm very grateful for any help regarding this issue! :-)