@a2lix/symfony-collection 中文文档教程
A2LiX JS - symfony-collection
使用 vanilla JS
Install
首先你需要使用 yarn 或 npm 拉包
yarn add @a2lix/symfony-collection
或者
npm install @a2lix/symfony-collection
然后你可以使用 ES6
import a2lix_lib from '@a2lix/symfony-collection/src/a2lix_sf_collection';
或 symlink/copy 将它导入到你的文件中/ 将其移动到文件夹中并直接在 script
标记中引用它
How to
加载 a2lixsfcollection.min.js 文件的 dist 版本后或通过 ES6 方法导入,初始化 a2lix_lib.sfCollection,可选择自定义配置。
默认配置:
a2lix_lib.sfCollection.init({
collectionsSelector: 'form div[data-prototype]',
manageRemoveEntry: true,
lang: {
add: 'Add',
remove: 'Remove'
}
})
Example
<script src="__PATH_TO__a2lix_sf_collection.min.js"></script>
<script>
// A global initialization on all Symfony Form collection with manageRemoveEntry feature enable
a2lix_lib.sfCollection.init()
// OR a custom initialization with restricted scope of Symfony Form collection with manageRemoveEntry feature disable
a2lix_lib.sfCollection.init({
collectionsSelector: 'form div[data-a2lix-collection]',
manageRemoveEntry: false
})
</script>
Contribute help
docker run -it --rm --user $(id -u):$(id -g) --name a2lix_nodejs -v "$PWD":/usr/src/app -w /usr/src/app node:alpine npm install
docker run -it --rm --user $(id -u):$(id -g) --name a2lix_nodejs -v "$PWD":/usr/src/app -w /usr/src/app node:alpine npm run build
Demo
参见演示项目。
A2LiX JS - symfony-collection
Manage your Symfony Form collection simply with vanilla JS
Install
As first thing you need to pull the package using yarn or npm
yarn add @a2lix/symfony-collection
or
npm install @a2lix/symfony-collection
Then you can either import it in your files using ES6
import a2lix_lib from '@a2lix/symfony-collection/src/a2lix_sf_collection';
or symlink/copy/move it in a folder and reference it directly in a script
tag
How to
After you loaded the dist version of a2lixsfcollection.min.js file or imported through ES6 method, init a2lix_lib.sfCollection, optionnaly with custom configuration.
Default configuration:
a2lix_lib.sfCollection.init({
collectionsSelector: 'form div[data-prototype]',
manageRemoveEntry: true,
lang: {
add: 'Add',
remove: 'Remove'
}
})
Example
<script src="__PATH_TO__a2lix_sf_collection.min.js"></script>
<script>
// A global initialization on all Symfony Form collection with manageRemoveEntry feature enable
a2lix_lib.sfCollection.init()
// OR a custom initialization with restricted scope of Symfony Form collection with manageRemoveEntry feature disable
a2lix_lib.sfCollection.init({
collectionsSelector: 'form div[data-a2lix-collection]',
manageRemoveEntry: false
})
</script>
Contribute help
docker run -it --rm --user $(id -u):$(id -g) --name a2lix_nodejs -v "$PWD":/usr/src/app -w /usr/src/app node:alpine npm install
docker run -it --rm --user $(id -u):$(id -g) --name a2lix_nodejs -v "$PWD":/usr/src/app -w /usr/src/app node:alpine npm run build
Demo
See Demo project.
更多