Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Jun 30, 2014 @ 13:21
    Tim
    0

    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!

    :)

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Jun 30, 2014 @ 13:58
    Tim
    102

    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.

    :)

  • Brian Hvarregaard 21 posts 61 karma points
    Jan 09, 2016 @ 13:14
    Brian Hvarregaard
    0

    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?

  • Barry 7 posts 94 karma points MVP c-trib
    Apr 30, 2016 @ 09:57
    Barry
    0

    @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".

Please Sign in or register to post replies

Write your reply to:

Draft