0

I have the following list view:-

enter image description here

But I need to add the “+ Add new item” link inside another page. So can anyone advice how I can get the mark-up for add new item which will display the form inside a dialog box. I tried adding this inside a code snippet:-

<a target="_self" onclick="NewItem2(event, &quot;http://tvstg01/_layouts/15/listform.aspx?PageType=8&amp;ListId=%7B9F1C7DA9%2D2238%2D43E5%2D8AA0%2D9A83A1792130%7D&amp;RootFolder=&quot;); return false;" data-viewctr="1" href="amp;ListId=%7B9F1C7DA9%2D2238%2D43E5%2D8AA0%2D9A83A1792130%7D&amp;RootFolder=" id="idHomePageNewItem" class="ms-addnew">Add new item</a>

But the new form will not be shown inside a dialog, although inside the list settings I mentioned to show edit form inside a dialog:-

enter image description here

Of course i original link will show new form inside a dialog box, but if i copy the related markup inside a code snippet the form will not be shown inside a dialog ...

2

try using the below script in CEWP:

<a onclick="modalcall()" href="#">Add New Item</a><script type="text/javascript">
function modalcall() {
    SP.UI.ModalDialog.showModalDialog({
        url: "NewForm.aspx",
        title: "New Item",
        //allowMaximize: true, 
        //showClose: true, 
        dialogReturnValueCallback: refreshCallback
    });
};
function refreshCallback(dialogResult, returnValue) {
    SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.