예제 #1
0
 /**
  * Register client assets
  */
 public function registerAssets()
 {
     $view = $this->getView();
     SortableAsset::register($view);
     $this->registerPlugin('sortable');
     $id = 'jQuery("#' . $this->options['id'] . '")';
     if ($this->disabled) {
         $js = "{$id}.sortable('disable');";
     } else {
         $js = "{$id}.sortable('enable');";
     }
     $view->registerJs($js);
 }
예제 #2
0
파일: index.php 프로젝트: BoBRoID/new.k-z
<?php

use kartik\grid\GridView;
use rmrevin\yii\fontawesome\FA;
use rmrevin\yii\fontawesome\FontAwesome;
use yii\bootstrap\Html;
$this->title = 'Анонсы';
$this->params['breadcrumbs'][] = $this->title;
\kartik\sortable\SortableAsset::register($this);
$js = <<<'JS'
var setSortable = function(){
    $(".sortableGrid tbody").sortable({
        forcePlaceholderSize: true,
        items: 'tr',
        placeholder: '<tr><td colspan="6">&nbsp;</td></tr>'
    }).on('sortupdate', function(e){
        var rows = $(this).find('tr'),
            positions = [];
            
        $.each(rows, function(key, item){
             positions.push({id: $(item).attr('data-key'), position: key + 1})
        });
        
        $.ajax({
            url: '/announcements/sort',
            method: 'post',
            data: {
                items: positions
            },
            success: function(data){
                $.each(rows, function(key, item){