We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

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: http://patterns.perchcms.com/components/detail/modal-dialog.html

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

  • 1 year ago
Drew McLellan

Drew McLellan 2637 points
Perch Support

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

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 2637 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.