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

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

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.

Author

Jason Prothero

Jason leads the team at ProWorks Corporation, an Umbraco Platinum Partner specializing in complex Umbraco CMS builds, integrations, support, and upgrades. With 17+ years of Umbraco experience and an Umbraco MVP, he has led dozens of successful projects from versions as old as Umbraco 4 to the latest Long-Term Supported (LTS) releases. Jason is also leading the charge at ProWorks around AI and how to responsibly integrate AI into Umbraco and websites to create ROI and not simply as a novelty.

comments powered by Disqus
back to top