Copied to clipboard

Flag this post as spam?

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


  • Bert Detailleur 21 posts 122 karma points
    Jun 08, 2018 @ 06:37
    Bert Detailleur
    0

    Custom Property editors - is loading javascript files dynamically possible?

    Hi all!

    For Custom Property Editors, you normally set scripts in the package.manifest. which is fine in most cases and works great.

    But what if you want to load for example the google maps api? There you can add paramaters to the url like language and apikey.

    Can you add values directly from the config part of the manifest? Or can you dynamically load a script from the controller?

    What are the possiblities/best practices?

    Thanks in advance!

    Bert

  • Søren Kottal 712 posts 4570 karma points MVP 6x c-trib
    Jun 08, 2018 @ 07:37
    Søren Kottal
    100

    Hi Bert

    You can dynamically load assets using the assets service. Check out the docs here: https://our.umbraco.org/apidocs/ui/#/api/umbraco.services.assetsService

    For your case, which I suspect is the configuration of API keys for Google Maps, I would have a prevalue config option for the API key, or save it in the appSettings section of web.config (but then you would need some kind of API method, to get it from there).

  • Bert Detailleur 21 posts 122 karma points
    Jun 08, 2018 @ 09:24
    Bert Detailleur
    0

    Hi Søren

    Thanks for the advice! This is exactly what I'm looking for :)

Please Sign in or register to post replies

Write your reply to:

Draft