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?
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.
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...
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.
Thanks Stephen, some great advice there.
B
is working on a reply...
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.