But what if you have migrated your application from 2010 to 2013 and now end user wants the dialog box instead of navigating to another page? No need to worry, SharePoint has provided you option to choose either dialog box or 2013 behavior.
<
script
src
=
"/jquery-1.9.1.js"
></
>
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'));
});
$(this).attr('href','javascript:openDialogBox("' + $(this).attr('href') + '")');
}, 3000);
</
What this code snippet does here is, it finds all meeting titles which are hyperlinks on the Month view and changes href attribute to call ‘openDialogBox’ JavaScript method. And ‘openDialogBox’ opens the page in dialog box.
In this way you can use dialog boxes to show forms in SharePoint 2013.
Balaji M Kundalam edited Revision 6. Comment: Removed extra spaces.
Maheshkumar S Tiwari edited Revision 5. Comment: Added tags and minor formatting
Rahul A Shinde edited Revision 2. Comment: TOC added