Copied to clipboard

Flag this post as spam?

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


  • Nathan Woulfe 447 posts 1664 karma points MVP 5x hq c-trib
    Jan 28, 2018 @ 11:28
    Nathan Woulfe
    0

    Using contentpicker in a package - model updates not reflected in the view

    Hi all

    I'm rendering a content picker into a package, which is all working nicely, using the umb-property-editor directive and providing a data model (alias, view and a simple config).

    It's rendering nicely, I can select a node or two, and save it off to my settings store. Issue is that on reloading the view, the content picker does not update with the selected values - these are fetched from the DB, and when the promise resolves, I update the picker model with the new value.

    That should (I thought) trigger the watch in the content picker controller and update the render model. The watch never fires on receipt of the data (it does on the initial page load, when the value is empty).

    Has anyone done similar?

            // other controller code
    
            vm.excludeNodesModel = {
                view: 'contentpicker',
                alias: 'excludeNodesPicker',
                config: {
                    multiPicker: '1'
                }
            }
    
            $q.all(promises)
                .then(function (resp) {
                    // code removed for brevity
                    // this value is a comma-delimited list of node ids, so is a valid value for the contentpicker
                    if (vm.settings.excludeNodes) {
                         // thought this would trigger the watch on the contentpicker value...
                         vm.excludeNodesModel.value = vm.settings.excludeNodes;
                    }           
            ...
    
  • Nathan Woulfe 447 posts 1664 karma points MVP 5x hq c-trib
    Jan 29, 2018 @ 08:35
    Nathan Woulfe
    0

    Found a solution - it's a bit messy but does the job.

    Basically needed to take the data returned from the server, access the directive scope, then pump my data in via the add() function. It means fetching each content item, so a bit of overhead, but in my case there would only ever be a handful of ids at most, so not a huge deal

    Example of the solution is here -> https://github.com/nathanwoulfe/Plumber/blob/fde77520d0dd8e1e81e39fa4505b513b04d4fe05/Workflow/App_Plugins/Workflow/Backoffice/controllers/workflow.settings.controller.js#L23-L39

Please Sign in or register to post replies

Write your reply to:

Draft