Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • z4kk 24 posts 83 karma points
    Jun 29, 2018 @ 21:24
    z4kk
    1

    Force refresh backend page after save & publish

    Hello!
    Is there any possibility to force refresh backend page after successful save & publish?

    I was trying to use Umbraco.Web.UI.Pages.ClientTool with no any luck.

    I'll just need to refresh page on come conditions in IApplicationEventHandler.

    Thx! ;)

  • z4kk 24 posts 83 karma points
    Jun 30, 2018 @ 07:52
    z4kk
    2

    Ok. Here is my hack

    In file ~/Umbraco/Js/umbraco.services.js I modified function contentEditingHelper. In line 869 (for Umbraco 7.11.0 ) I had insert next code:

       self.handleSuccessfulSave({
                                scope: args.scope,
                                savedContent: data,
                                rebindCallback: function () {
                                    rebindCallback.apply(self, [
                                        args.content,
                                        data
                                    ]);
                                    /* >>> THIS IS INSERTED CODE */
                                    if (data.documentType.alias === 'ServiceJob') {
                                        window.location.href = '/umbraco/#/content/content/edit/' + data.id + '/';
                                    }
                                    /* <<< END OF INSERTED CODE */
                                }
                            });
    

    This working but not very solution. Is there any way to inject this code without modification core umbraco js files? I'm worried what I'm lost this code during Umbraco update.

  • Marcel van Helmont 68 posts 259 karma points c-trib
    Jun 30, 2018 @ 09:15
    Marcel van Helmont
    101

    Matt have wrote a article about tweaking the backoffice https://24days.in/umbraco-cms/2015/umbraco-7-back-office-tweaks/

    Maybe you can do it with a interceptor look at tweaking logic

  • z4kk 24 posts 83 karma points
    Jul 04, 2018 @ 11:43
    z4kk
    2

    Thx! Awesome technique!
    Here my solution:

    angular.module('umbraco.services').config([
        '$httpProvider',
        function($httpProvider) {
            $httpProvider.interceptors.push(function($q, $location) {
                return {
                    'response': function(response) {
                        if (response.config.url.includes('/umbraco/backoffice/UmbracoApi/Content/PostSave')) {
                            if (response.status === 200) {
                                $location.path('/content/content/edit/' + response.data.id + '/');
                            }
                        }
                        return response;
                    }
                };
            });
        }
    ]);
    
  • Dennis Milandt 190 posts 517 karma points
    Sep 26, 2019 @ 11:21
    Dennis Milandt
    0

    Exactly what I came here to find. I was having the same issue with Umbraco not displaying property values that had been updated in the Saving event.

    However, I couldn't get this to work:

    $location.path('/content/content/edit/' + response.data.id + '/');
    

    I had to use location.href to make it work.

  • Tobias Klika 101 posts 570 karma points c-trib
    Sep 26, 2019 @ 11:38
    Tobias Klika
    1

    You can just use location.reload() if you want to stay on the same page ;-)

  • Dennis Milandt 190 posts 517 karma points
    Sep 26, 2019 @ 11:40
    Dennis Milandt
    0

    Thanks! Good point!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies