I have implemented a feature that once activated adds a heading called Home, and a link underneath to a NewForm.aspx
like such:
// Add Home node
var mainListsNode = new SPNavigationNode("Home", web.Url, true);
leftNav.AddAsFirst(mainListsNode);
// Add NewForm link
node = new SPNavigationNode("Add New Item", string.Format("{0}/Lists/CustomList/NewForm.aspx", web.Url), true);
homeNode.Children.AddAsLast(node);
My requirement is now to make that link pop open the modal dialog box instead. I achieved this easily in my webpart where I can use JavaScript like this:
<a href="#" onclick="javascript:openDialog();return false;" target="_self">
function openDialog() {
var options = {
url: '/sites/TESTSITE/Lists/CustomList/NewForm.aspx?IsDlg=1',
title: "Add New Item",
dialogReturnValueCallback: itemNotificationSent,
allowMaximize: false
};
SP.UI.ModalDialog.showModalDialog(options);
How can I achieve this in my first example? Bonus points for advising me how I can also add my dialogReturnValueCallback
as my second example:
function itemNotificationSent(dialogResult, returnValue) {
if (dialogResult == SP.UI.DialogResult.OK) {
SP.UI.Notify.addNotification('An Item was added. Thank you!');
}
else {
SP.UI.Notify.addNotification('The "Item Add" was cancelled...');
return false;
}
}