Copied to clipboard

Flag this post as spam?

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


  • Bo Jacobsen 300 posts 1329 karma points
    Jun 19, 2019 @ 14:11
    Bo Jacobsen
    0

    umb-property-editor with multiurlpicker view wont save my scope model value

    Hi all.

    When i save and publish the page my $scope.model.value does not get updated. Well it does until i reload the page :)

    <div ng-controller="...Controller as vm">
        <umb-property-editor model="vm.urlPicker"></umb-property-editor>
    </div>
    
    (function () {
        "use strict";
    
        function controller($scope) {
    
            var vm = this;
    
            vm.urlPicker = {
                view: 'multiurlpicker',
                config: {
                    maxNumber: 1,
                    minNumber: 0
                },
                value: $scope.model.value
            };
    
            $scope.$watch('vm.urlPicker.value', function (newValue, oldValue) {
                console.log("watch");
                $scope.model.value = newValue;
            }, true);
    
            $scope.$on('formSubmitting', function () {
                console.log("formSubmitting");
            });
        }
    
        angular.module("umbraco").controller("...Controller ", controller);
    })();
    

    formSubmitting is firing first and then watch and maybe thats why the model dont get updated. what can i do? or what do i do wrong?

    Umbraco.PropertyEditors.MultiUrlPickerController is using formSubmitting to set the value.

    $scope.$on('formSubmitting', function () {
                $scope.model.value = $scope.renderModel;
            });
    
  • Bo Jacobsen 300 posts 1329 karma points
    Jun 20, 2019 @ 07:34
    Bo Jacobsen
    0

    I found out that it will save the value if i preset the $scope.model.value to start with an array with a value in it, but it wont save an empty value or array.

    This wont save it

    $scope.model.value = undefined;
    // OR
    $scope.model.value = null;
    // OR
    $scope.model.value = [];
    

    This will save changes, unless the value is empty

    $scope.model.value = [{
        icon: "icon-home color-black",
        isMedia: undefined,
        name: "Home",
        target: undefined,
        udi: "umb://document/c6eb250f2ec6441ab9884e7452c88dfe",
        url: "/"
    }];
    

    So what to do?

Please Sign in or register to post replies

Write your reply to:

Draft