Missing helper: "assetURL"

Answered

2 Comments

  • Bryan Flynn
    Comment actions Permalink

    Hi Tom -- because how apps are written under the "v2" framework have changed (versus the "v1" framework) , the assetURL helper no longer exists in that form.

    The app under the v2 framework is essentially a completely encapsulated set of files hosted by Zendesk and referenced inside an iframe. Any additional library functionality needs to be brought in explicitly by you (such as Handlebars or jQuery).

    Regardless, all your assets are now stored under the 'assets' folder, so to reference an asset file, you can just reference that file directly:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    </head>
    <body>
    <h2>Hello, World!</h2>
    <img src="logo.png" />

    <script src="https://assets.zendesk.com/apps/sdk/2.0/zaf_sdk.js"></script>
    <script>
    var client = ZAFClient.init();
    client.invoke('resize', { width: '100%', height: '200px' });
    </script>
    </body>
    </html>

    In this case, because the v2 app's iframe.html (the default name given when running 'zat new') is in the same directory as 'logo.png', there is not path that needs to precede the PNG file name.

    If you do need a fully qualified path, you can use the client.get('assetURL:name') method.

    Here are some other v1 -> v2 migration tips:

    https://github.com/zendesk/zendesk_app_framework_sdk/wiki/ZAF-SDK-v2-Feature-Parity-Status

    Hope this helps!

    0
  • Tom Harper
    Comment actions Permalink

    Many thanks Bryan for your helpful reply.  The solution was a lot simpler than I thought.  Thanks also for sharing the link on v1 vs. v2 feature comparison; that's a page I hadn't come across and it is very useful.

    Tom

    0

Post is closed for comments.

Powered by Zendesk