Skip to content

Commit 4489740

Browse files
author
Eugene Tupikov
committed
add an ability to modify JQuery sortable options
1 parent d9b0542 commit 4489740

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/renderers/BaseRenderer.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,20 @@ private function registerJsSortable()
430430
MultipleInputSortableAsset::register($view);
431431

432432
// todo override when ListRenderer will use div markup
433-
$options = Json::encode([
433+
$options = Json::encode($this->getJsSortableOptions());
434+
$js = "$('#{$this->id} table').sorting($options);";
435+
$view->registerJs($js);
436+
}
437+
438+
/**
439+
* Returns an array of JQuery sortable plugin options.
440+
* You can override this method extend plugin behaviour.
441+
*
442+
* @return array
443+
*/
444+
protected function getJsSortableOptions()
445+
{
446+
return [
434447
'containerSelector' => 'table',
435448
'itemPath' => '> tbody',
436449
'itemSelector' => 'tr',
@@ -445,9 +458,7 @@ function(item, container, _super, event) {
445458
wrapper.trigger(event, [item]);
446459
}
447460
")
448-
]);
449-
$js = "$('#{$this->id} table').sorting($options);";
450-
$view->registerJs($js);
461+
];
451462
}
452463

453464
/**

0 commit comments

Comments
 (0)