Copied to clipboard

Flag this post as spam?

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


  • Brendan Rice 372 posts 608 karma points
    Nov 25, 2012 @ 15:48
    Brendan Rice
    0

    Client dependency reference js file from XSLT

    I am workign on a project with a lot of XSLT files, most of which are for components. I need to register certain blocks of javascript that are specific to the components depending where they are used.

    I thought the best way of doing this was to use the client dependency framework to register the javscript per component (each component will have its own file).

    Is this recommended and is it possible to register js and css files through the client dependency framework using XSLT?

    Thanks...

  • Stephen 767 posts 2268 karma points c-trib
    Nov 25, 2012 @ 16:09
    Stephen
    2

    Look at library.RegisterJavaScriptFile method, which will let you register a script file. ClientDependency does not let you register inline scripts blocks, to the best of my knowledge. Also be aware of a cache issue: if you register a JavaScript file with ClientDependency from within a macro, and you cache the result of that macro... the dependency is _not_ cached ie when the (html) content is fetched from the cache, the dependencies are _not_ registered (since the code does not run) and will be missing.

  • Brendan Rice 372 posts 608 karma points
    Nov 25, 2012 @ 16:39
    Brendan Rice
    0

    Thanks Stephen, some great advice there.

    B

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies