Stay on page after save

Home Forums Classic DFFS Stay on page after save

Viewing 4 reply threads
  • Author
    Posts
    • #11229
      Lana
      Participant

        Hi Alexander!
        I have several web part pages using the same lists. These lists have places where my users need to input responses. I would like them to be able to input their response and stay on that page without getting redirected to the AllItems.aspx for the list. I tried the attached code, but it just takes me back to the AllItems.aspx in the modal window which I think will confuse my users. Is there a way to save a new item or an edit item and stay on the page they are working in?
        Thanks!
        Lana

      • #11232
        Lana
        Participant

          Here is the Attachment

        • #11278
          Alexander Bautz
          Keymaster

            Hi,
            I’m not sure I understand exactly what you mean. Where are the users write their input? – is it in an EditForm opened from the list view? I would think the default SharePoint behavior would be to redirect back to where you were?

            Please note that any “&Source=/Url/To/A/Page” in the URL will causer the page to redirect to this “Source” after save.

            Alexander

          • #11321
            Lana
            Participant

              Hi,
              I have created several Web Part Pages. Each page uses the same lists with different views.
              If you open the edit form for a list item, input information and save, SharePoint automatically redirects you back to the default view of the list that was just edited, away from the web part page. At least my SharePoint 2010 version does. I am unsure how else to describe this, so I have screenshots below.
              I need the redirect to not redirect. To just save the item and close the modal dialog box.
              Is this possible?
              Thanks!
              Lana

            • #11352
              Alexander Bautz
              Keymaster

                Hi Lana – I’m posting the solution we exchanged on email here to maybe help others.

                I’m not sure how this is set up as my test in a web part page will not redirect. You can try adding this to a CEWP / HTML form web part below the form:

                <script type="text/javascript">
                EditItemWithCheckoutAlert = function(a,b,c){
                            var dlg, options = {};
                            options.url = b;
                            options.dialogReturnValueCallback = function(a,b){
                                        if(a === 1){
                                                    alert("The item was edited");
                                        }else{
                                                    alert("The dialog was cancelled.")
                                        }
                            };
                            dlg = SP.UI.ModalDialog.showModalDialog(options);
                }
                </script>

                This code will alert the dialog “result” – these alerts must be removed, but they show you how you can do something when the dialog is closed.

                Hope this helps,
                Alexander

                • This reply was modified 8 years, 7 months ago by Alexander Bautz. Reason: fixed missing code snippet
            Viewing 4 reply threads
            • You must be logged in to reply to this topic.