1

I'm trying to write web-part for viewing list items. It contains link "add new item". I should create modal dialog for adding item, and it must work from every page.

So, I have JS for modal:

function openDialog(listUrl) {
    var options = SP.UI.$create_DialogOptions();

    options.title = "My Dialog Title";
    options.width = 400;
    options.height = 600;
    options.url = listUrl;

    SP.UI.ModalDialog.showModalDialog(options);
}

But it works only from list page. How can I fix it?

  • could u share the parameters which u are sending... – Pushpendra Aug 21 '13 at 5:32
1

You can try with the below code using a Content Editor web part.

Copy the HTML markup from the existing Add new item link and use it.

Example :

<SPAN style="POSITION: relative; WIDTH: 10px; DISPLAY: inline-block; HEIGHT: 10px;    OVERFLOW: hidden" class=s4-clust><IMG style="POSITION: absolute; TOP: -128px !important; LEFT: 0px !important" alt="" src="/_layouts/images/fgimg.png"></SPAN>
<A id=idHomePageNewItem class=ms-addnew onclick='javascript:NewItem2(event, "http://{sharepointurl}/_layouts/listform.aspx?PageType=8&amp;ListId={}&amp;RootFolder=");javascript:return false;' href="http://{sharepointurl}/_layouts/listform.aspx?PageType=8&amp;ListId={}&amp;RootFolder=" target=_self>Add new item</A>

Paste the HTML markup into the Content Editor web part

Or, you can refer to the below link

  1. http://kyleschaeffer.com/sharepoint/sharepoint-2010-pop-up-dialogs/

0

First add the page you created the new web part to the Pages library. Lets assume the page name is Page1.aspx. Then in the page you need to add the link to it add it like this.

<a href="javascript:OpenPopUpPage('/Pages/Page1.aspx');">Page Popup</a>

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.