Missing helper: "assetURL"



  • Bryan - Community Manager
    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>
    <meta charset="utf-8">
    <h2>Hello, World!</h2>
    <img src="logo.png" />

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

    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:


    Hope this helps!

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



Post is closed for comments.

Powered by Zendesk