简体   繁体   中英

Include .js file in another javascript file in alfresco

I'm working with alfresco and was wondering how to include a js file in another file. How do I deal with dependency when I want to use a library?

Thanks a lot

As Lista suggested, I created an answer :

I think this is what you need (from Alfresco documentation ) :

Importing scripts

This feature allows you to build libraries of scripts for use by other scripts at runtime. The syntax to import the scripts is specific to Alfresco and is not a feature of standard JavaScript. For example, the syntax, as supported by most web browsers, is not part of standard ECMA JavaScript and will not work in Alfresco.

The syntax to import other scripts is very strict and you must follow it exactly; otherwise, the import may fail. Import directives must be the first lines in the JavaScript file. This means that no code or comments are allowed above those lines, and the usual JavaScript code and comments appear after the import lines. Only the following syntax variants are supported:

  • Import a script from the repository using a name-based path:

     <import resource="/Company Home/Data Dictionary/Scripts/library.js"> 
  • Import a script from the repository using a NodeRef reference:

     <import resource="workspace://SpacesStore/6f73de1b-d3b4-11db-80cb-112e6c2ea048"> 
  • Import a script from a Java classpath location:

     <import resource="classpath:alfresco/extension/myutils.js"> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM