Thread tagged as: Question, Api, Add-on-development

How does one trigger a Perch Modal Dialog in an add-on?

I'm updating some little admin console add-ons to appear more Perch-like using the pattern library.

It would be great to use the Modal Dialog as seen here:

The markup is clear, but I can't find any documentation on how to trigger the dialog to appear.

Can you point me in the right direction?

Perch: 3.0.8

Kirk Roberts

Kirk Roberts 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

var my_dialog = Perch.UI.Dialog.create($('#content-thereof'));;

Thanks, Drew! Is there a "Perch-y" way to know when Perch.UI.Dialog is available in JavaScript? Or is it just a matter of detecting when all page assets have loaded?

The Perch object didn't seem to be available on page load, so I used a setTimeout loop to detect when it was. Not elegant, but it works.

If there is a better way to do this, I'd be happy to hear it!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you not registering your code with Perch?

Apparently not. How does one do that?

I retract the question, because I'm realizing it's a big topic (app development).

In this case, I just have a single page of links that I wanted to wrap in the Perch interface. I've been able to accomplish that copying over some API calls from the core apps. So I'm good to go.