Copied to clipboard

Flag this post as spam?

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


  • John Alphonso Yarlott 10 posts 101 karma points
    Jul 28, 2015 @ 13:18
    John Alphonso Yarlott
    0

    question on how to use dialogService.open

    Greetings:

    I'm attempting to use dialogService.open to open a custom dialog and then access the information submitted by the user. The problem I'm seeing is that the data variable returned to the callback function isn't getting any data.

    Here is the function being called in my controller:

    angular.module("umbraco").controller("Com.Bisk.CustomController", function ($scope, $timeout, dialogService) {
            $scope.setImage = function(imageUrl){
            dialogService.open({
                showDetails: true,
                template: '../App_Plugins/MyPlugin/mycustomdialog.html', 
                show: true, 
                callback: function (data) {
                    $scope.control.value = {
                        // data coming back as 'undefined'
                        altText: data.altText
                        };
                    }
                });
            };
        }
    

    Here is my view:

    <form ng-controller="Com.Bisk.CustomController">
          <umb-pane>
              <umb-control-group label="Alt Text">
                  <input type="text"
                         class="umb-editor umb-textstring"
                         ng-model="target.altText" />
              </umb-control-group>
          </umb-pane>
      </form>
    
  • Anders Bjerner 487 posts 2989 karma points MVP 7x admin c-trib
    Jul 28, 2015 @ 14:56
    Anders Bjerner
    100

    Hi John,

    How does the view of your dialog look?

    Values entered in the dialog aren't automatically sent back to your original view, so you need to call something like $scope.submit(data). That should give you a value in your callback function ;)

  • Simon Justesen 74 posts 193 karma points
    Jul 28, 2015 @ 16:46
    Simon Justesen
    1

    You could also listen for events to get your data back

    MainWindow controller:

    // listening for an ItemDeleted event to happen
    $scope.$on('ItemDeleted', function (event, args) {
            console.log('id to delete: ' + args.idToDelete);
            $scope.reloadBookingList();
        });
    

    In your dialog controller:

    shouldDelete = confirm('Are you sure you want to delete this item?');
            if (shouldDelete) {
                    bookingResource.deleteBooking(id);
                    notificationsService.success("System message", "item deleted");
    
    // broadcasting event - passing data back to MainWindow
                    $rootScope.$broadcast('ItemDeleted', { idToDelete: id });
                    dialogService.closeAll();
    
            }
    
  • John Alphonso Yarlott 10 posts 101 karma points
    Jul 29, 2015 @ 10:10
    John Alphonso Yarlott
    0

    Simon and Anders: thank you both! It turns out I just needed to add the correct ng-model attributes and then submit(my-model-name).

Please Sign in or register to post replies

Write your reply to:

Draft