Skip to content

Commit

Permalink
added option to disable reloading after succes sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
jirisvoboda committed Jan 28, 2016
1 parent 9f4cdfd commit 48079cc
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions widgets/ListView.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* @copyright Copyright (c) 2014 icron.org
* @license http://yii2metronic.icron.org/license.html
Expand Down Expand Up @@ -42,7 +41,7 @@ public function init()
protected function initSortable()
{
$route = ArrayHelper::getValue($this->sortable, 'url', false);

if ($route)
{
$url = Url::toRoute($route);
Expand All @@ -57,12 +56,18 @@ protected function initSortable()
}

$options = json_encode(ArrayHelper::getValue($this->sortable, 'options', []));

$view = $this->getView();
$view->registerJs("jQuery('#{$this->id}').SortableListView('{$url}', {$options});");
$view->registerJs("jQuery('#{$this->id}').on('sortableSuccess', function() {jQuery.pjax.reload(" . json_encode($this->clientOptions) . ")})", \yii\web\View::POS_END);

$reload = ArrayHelper::getValue($this->sortable, 'reload', true);

if ($reload)
{
$view->registerJs("jQuery('#{$this->id}').on('sortableSuccess', function() {jQuery.pjax.reload(".json_encode($this->clientOptions).")})", \yii\web\View::POS_END);
}

ListViewSortableAsset::register($view);
}
}

}
}

0 comments on commit 48079cc

Please sign in to comment.