Copied to clipboard

Flag this post as spam?

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


  • Paul de Quant 403 posts 1520 karma points
    Aug 17, 2018 @ 07:47
    Paul de Quant
    0

    $scope.control.value gets wiped on publish

    Hello,

    I have a custom grid control, which opens an overlay. The issue I have at the moment, is that the overlay itself works fine and I can see it's recording the data I enter in the text boxes. I click submit int he overlay, the view updates great. That is until I click publish, which then wipes the data I've just added.

    Here's my code:-

    angular.module("umbraco").controller("mycontrols.latest",
    function ($scope, $rootScope, $http, $timeout, userService, dialogService, assetsService, entityResource, mediaHelper) {
    
        $scope.openOverlay = openOverlay;
    
        function openOverlay() {
    
            $scope.overlay = {
                title: "Edit Latest Events",
                subtitle: "Modify your latest events feed",
                view: "/App_Plugins/Controls/Editors/Overlays/LatestEventsOverlay.html",
                editModel: $scope.control.value,
                show: true,
                setContentId: function () {
                    dialogService.treePicker({
                        multiPicker: false,
                        section: "content",
                        treeAlias: "content",
                        callback: function (data) {
                            $scope.control.value.linkprop = {
                                id: data.id,
                                udi: data.udi,
                                name: data.name
                            };
                        }
                    });
                },
                submit: function (model) {
                    $scope.overlay.show = false;
                    $scope.overlay = null;
    
                    $scope.ModelData = model.editModel;
                },
                close: function (oldModel) {
                    $scope.overlay.show = false;
                    $scope.overlay = null;
                }
            };
        }
    
        $timeout(function () {
            if ($scope.control.$initializing) {
                $scope.control.value = {
                    linkprop: null
                };
            }
        }, 200);
    
    });
    

    Can anyone see any obvious reason, why the $scope.control.value would get wiped when you publish the page?

    Thanks

    Paul

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Aug 17, 2018 @ 07:49
    Jan Skovgaard
    0

    Hi Paul

    Maybe there is something that I don't fully know or understand but I would say that you should use $scope.model.value instead of $scope.control.value

    /Jan

  • Paul de Quant 403 posts 1520 karma points
    Aug 17, 2018 @ 07:51
    Paul de Quant
    0

    Hi Jan,

    Thanks for the quick response, should I then replace every instance of $scope.control.value with $scope.model.value?

    Thanks

    Paul

  • Paul de Quant 403 posts 1520 karma points
    Aug 17, 2018 @ 07:59
    Paul de Quant
    0

    Hi Jan,

    Just tried replacing all instances of control.value and it does work now. What I don't quite understand is that we have other controls that use control.value as part of the overlay and these seem to work fine, also, does saving to scope.model have any impact on Courier and transferring pages. I sort of remember having an issue with this previously hence the idea to use $scope.control.

    Thanks Paul

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Aug 19, 2018 @ 17:40
    Jan Skovgaard
    0

    Hi Paul

    Happy to hear that you managed to get it working - I don't have that much experience using Courier so I don't know what potential issues you could be facing and if it's related or caused by something else.

    Well I'm fairly certain that unless you use $scope.model in order to have Umbraco save the values. Not sure how you have used $scope.control in other extensions but perhaps the values they store are somehow mapped to $scope.model? Or maybe there is something I don't know about, which can certainly also be the case :)

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft