Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
    
could u share the parameters which u are sending... –  Pushpendra Aug 21 '13 at 5:32
add comment

1 Answer

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/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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