demogorgorn/yii2-sortable
Composer 安装命令:
composer require demogorgorn/yii2-sortable
包简介
Create sortable lists and grids using HTML5 drag and drop API for Yii 2.0.
README 文档
README
Yii2 wrapper for Sortable (https://github.com/RubaXa/Sortable), a minimalist JavaScript library for reorderable drag-and-drop lists on modern browsers and touch devices.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist demogorgorn/yii2-sortable "*"
or add
"demogorgorn/yii2-sortable": "*"
to the require section of your composer.json file.
How to use
On your view file.
// items data example <?php $items = [ [ 'content' => 'item-1', 'options' => ['data-id' => 'optional data attribute'], ], [ 'content' => 'item-name', ] ]; ?> <?php echo \demogorgorn\sortable\Sortable::widget([ 'varName' => 'editable', 'editable' => true, 'options' => [ 'class' => 'block__list', 'id' => 'currencylist', ], 'items'=> $items, 'clientOptions' => [ 'animation' => 150, 'filter' => '.js-remove', 'onFilter' => new \yii\web\JsExpression('function (evt) { var code = evt.item.getAttribute("data-id"); evt.item.parentNode.removeChild(evt.item); }'), 'onUpdate' => new \yii\web\JsExpression('function (evt) { // do something with js }'), ], ]); ?>
统计信息
- 总下载量: 337
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD
- 更新时间: 2015-02-26