ProWorks Blog

How to Pass Data to the Umbraco 7 dialogService on open()

By  |  Thursday, February 27, 2014  |  , , ,  |  1 comment

If you're building a package for Umbraco 7 using AngularJS and you eventually find yourself needing to use the dialogService, there is an undocumented parameter that may be of some help.

I found myself in a situation where I needed an edit button on a list of items in an ngRepeat and the edit button needed to pass in its model to the dialogService.  Well, according to the Umbraco 7 developer documentation, the only way seemed to be to tie it to the scope or create a new scope.

However, looking through the Umbraco 7 source it turns out there is an additional parameter called dialogData that allows the open() method to pass in additional data that the dialog controller can use.

You can see this in the defaults object in the dialog.service.js code:

           var defaults = {
              container: $("body"),
              animation: "fade",
              modalClass: "umb-modal",
              width: "100%",
              inline: false,
              iframe: false,
              show: true,
              template: "views/common/notfound.html",
              callback: undefined,
              closeCallback: undefined,
              element: undefined,
              //this allows us to pass in data to the dialog if required 
              //which can be used to configure the dialog
              //and re-use it for different purposes. It will set on to the 
              //$scope.dialogData if it is defined.
              dialogData: undefined
           };

 It appears to be used internally as well so I assume its here to stay, but since its undocumented you should verify when new releases are published.

1 comment for “How to Pass Data to the Umbraco 7 dialogService on open()”

  1. Posted 7/24/2014 at 7:22:35 AM
    Gravatar of Shig

    Thanks for posting this :D I didn't know about closeCallback - you've really helped me out today

Post a comment

Comments closed