none
how to open Modal list form in SharePoint 2013

    Question

  • Hi,

    in SharePoint 2010 the following opens a new item form in a Modal dialog, but in SharePoint 2013 it opens the form in a new window:

    <input onclick="javascript:NewItem2(event, &#39;http://intranet.pcycnsw.org.au/activities/pcycbrandedprograms/toipadmin/Lists/Courses/Item/newifs.aspx&#39;);javascript:return false;" type="submit" target="_self" value="Add a Course"/>

    In SP 2010 you get a nice pop up modal dialog and the user doesn't leave the page they launched the dialog from.

    In SP 2013 the same code works, but doesn't open the form modally - instead it opens the form in a full page.

    What is the equivalent method for SP 2013 so that I can get the form to open in a modal pop up like in SP2010?


    Mark

    Monday, September 30, 2013 6:34 AM

Answers

  • I've checked the suggested solution, It works in my dev. environment.

    Alternative you can use example of SP.UI.ModalDialog.showModalDialog function

    function dialogfunction(pageUrl) {
    var options = { url: pageUrl, width: 800, height: 600 };
    SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
    }
    

    Monday, September 30, 2013 9:52 AM

All replies

  • In SharePoint 2013 list settings parameter "Launch forms in a dialog" by default set to FALSE.

    If you want to open form in dialog using "NewItem2" function, set "Launch forms in a dialog" TRUE.

    You can use SP.UI.ModalDialog.showModalDialog as well.
    Monday, September 30, 2013 7:22 AM
  • Hi Sergey

    the list is already set to launch forms in a dialog. Can you give me a pointer on how to use the alternative method you mentioned?


    Mark

    Monday, September 30, 2013 9:37 AM
  • I've checked the suggested solution, It works in my dev. environment.

    Alternative you can use example of SP.UI.ModalDialog.showModalDialog function

    function dialogfunction(pageUrl) {
    var options = { url: pageUrl, width: 800, height: 600 };
    SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
    }
    

    Monday, September 30, 2013 9:52 AM
  • Hi,

    while Sergey's answer may well be correct and worthy of being marked as the answer, I actually found another post: http://social.technet.microsoft.com/Forums/sharepoint/en-US/e5fd38ca-0f77-4ce8-b607-f3c513e56289/on-form-button-click-launch-another-form-in-a-modal-window?forum=sharepointgeneralprevious 

    which gave me a much simpler method. It certainly works for my requirements. Here's a sample:

    <input id="clickMe" onclick="javascript:OpenPopUpPage('http://sitecollection/subsite/Lists/Tasks/AllItems.aspx');" type="button" value="clickme"/>

    So basically I replaced the "javascript:NewItem2(event," portion to "javascript:OpenPopUpPage(" and my forms open in a pop up.

    Hope this helps someone else.

    Mark


    Mark

    Monday, October 07, 2013 2:20 AM