Copied to clipboard

Flag this post as spam?

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


  • Lee 1130 posts 3088 karma points
    Mar 30, 2016 @ 11:02
    Lee
    0

    Manually Populating Media Picker In Custom Angular View

    I have a custom angular controller/view which opens up the side dialogue and renders my Html.

    Within this custom view, I am rendering a Multiple Media Picker datatype using

            datatypeResource.getByName('Vehicle Image Picker').then(function (result) {
                $scope.vehicleImages = [
                   {
                       alias: 'vehicleImages',
                       label: 'Vehicle Images',
                       view: result.data.view,
                       config: result.data.config,
                       value: $scope.model.vehicleQuery.Vehicle.ImageIds
                   }
                ];
            });
    

    Which works really well! However, when the user clicks a button I am going off to an external web service. Grabbing about 6 images, downloading, adding to the media and then returning the Id's.

    I am then setting the value like so

    $scope.vehicleImages[0].value = "45641,46546,6546"
    

    But I want to refresh the media picker 'view' to show these images have been picked straight away (Like it does in Umbraco when you pick an image from the dialogue normally).

    Currently it saves, but the user has to close and then re-opon the dialogue to see the picked images.

    Any idea how I trigger/force the media picker to show them straight away?

  • Lee 1130 posts 3088 karma points
    Mar 30, 2016 @ 14:32
    Lee
    0

    Anyone??

  • Anders Bjerner 487 posts 2989 karma points MVP 7x admin c-trib
    Mar 30, 2016 @ 15:13
    Anders Bjerner
    0

    Do you have some more code to show?

    I can't tell from your code, but there is a chance that you might do something outside of the Angular event system (eg. if using jQuery for your call), and changes to your model won't appear immediately then.

    If that is the case, you can look a bit into $scope.$apply() (which sorta forces your view to update). Or you can post a bit more of your code here, I can have another look at it ;)

  • Jon R. Humphrey 164 posts 455 karma points c-trib
    Mar 30, 2016 @ 18:03
    Jon R. Humphrey
    0

    Are you using $watch on the returned values to see when they're updated? Would need more code to analyse and help further? J

  • Lee 1130 posts 3088 karma points
    Mar 30, 2016 @ 18:20
    Lee
    0

    Thanks chaps for the replies. I actually cheated in the end.... I just called the same method again above and in the 'then' method populated the object with the new values and it works fine :)

Please Sign in or register to post replies

Write your reply to:

Draft