Access navigationService and notificationService from iFrame
Hi,
I have been creating a custom section that wraps an existing MVC app, that has been moved into an area, and had it's navigation and menus ported to a custom section and tree.
So far, so good, however, I have one final thing to figure out and I'm done (and I'll write a blog post about the whole process once I'm done, as it's been quite the learning experience).
Does anyone know how to access the notification service, or navigation service, from within an iFrame in the back office. The pages are MVC, and aren't part of Umbraco. I would however, like to use the notification service to display alerts when things are done like clicking save, and reload the tree when I rename something in the MVC app.
If I was using the old webforms, I'd just use the ClientTools class, but these pages aren't webforms, and they're not really part of the main Umbraco app, so I guess I'm going to have to do it all client side. I just can't figure out how to get a hold of the services from a non-angular bit of code in an iFrame.
Figured it out! It's not too tricky, you just need to get the parent scope and then access it's services using the angular injector. Here's some example code for calling the notificationsService:
parent.angular.element(parent.document).injector().get('notificationsService').success("Success", "Something non-angular has happened in an iFrame!!!");
You can swap the service name out in the get to grab any of the core Umbraco services, or any custom ones that you've created yourself, and access them as if you were on the parent page. So far seems to work pretty well.
Stumpled across this thread while looking for a solution to a similar issue. Im trying to show another MVC application in an iframe in a custom section. No problem in doing this - except that i cant get rid of the loading animation, when i have an iframe. It always show on top of my iframe. Forever loading. Did you run into this problem?
@brian: I think recent Umbraco versions fix the loading animation issue that you were seeing in the iFrame, but if you are still seeing it try setting the iFrame background css to "none".
Access navigationService and notificationService from iFrame
Hi,
I have been creating a custom section that wraps an existing MVC app, that has been moved into an area, and had it's navigation and menus ported to a custom section and tree.
So far, so good, however, I have one final thing to figure out and I'm done (and I'll write a blog post about the whole process once I'm done, as it's been quite the learning experience).
Does anyone know how to access the notification service, or navigation service, from within an iFrame in the back office. The pages are MVC, and aren't part of Umbraco. I would however, like to use the notification service to display alerts when things are done like clicking save, and reload the tree when I rename something in the MVC app.
If I was using the old webforms, I'd just use the ClientTools class, but these pages aren't webforms, and they're not really part of the main Umbraco app, so I guess I'm going to have to do it all client side. I just can't figure out how to get a hold of the services from a non-angular bit of code in an iFrame.
Any help or advice greatly appreciated!
:)
Figured it out! It's not too tricky, you just need to get the parent scope and then access it's services using the angular injector. Here's some example code for calling the notificationsService:
You can swap the service name out in the get to grab any of the core Umbraco services, or any custom ones that you've created yourself, and access them as if you were on the parent page. So far seems to work pretty well.
:)
Stumpled across this thread while looking for a solution to a similar issue. Im trying to show another MVC application in an iframe in a custom section. No problem in doing this - except that i cant get rid of the loading animation, when i have an iframe. It always show on top of my iframe. Forever loading. Did you run into this problem?
@brian: I think recent Umbraco versions fix the loading animation issue that you were seeing in the iFrame, but if you are still seeing it try setting the iFrame background css to "none".
is working on a reply...