Class yii\jui\Sortable

Inheritanceyii\jui\Sortable » yii\jui\Widget » yii\base\Widget
Available since version2.0

Sortable renders a sortable jQuery UI widget.

For example:

echo Sortable::widget([
    'items' => [
        'Item 1',
        ['content' => 'Item2'],
        [
            'content' => 'Item3',
            'options' => ['tag' => 'li'],
        ],
    ],
    'options' => ['tag' => 'ul'],
    'itemOptions' => ['tag' => 'li'],
    'clientOptions' => ['cursor' => 'move'],
]);

See also http://api.jqueryui.com/sortable/.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$clientEvents array The event handlers for the underlying jQuery UI widget. yii\jui\Widget
$clientOptions array The options for the underlying jQuery UI widget. yii\jui\Widget
$itemOptions array List of HTML attributes for the item container tags. yii\jui\Sortable
$items array List of sortable items. yii\jui\Sortable
$options array The HTML attributes for the widget container tag. yii\jui\Sortable

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$clientEventMap array Event names mapped to what should be specified in `. yii\jui\Sortable

Public Methods

Hide inherited methods

MethodDescriptionDefined By
init() Initializes the widget. yii\jui\Widget
renderItems() Renders sortable items as specified on $items. yii\jui\Sortable
run() Renders the widget. yii\jui\Sortable

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
registerClientEvents() Registers a specific jQuery UI widget events yii\jui\Widget
registerClientOptions() Registers a specific jQuery UI widget options yii\jui\Widget
registerWidget() Registers a specific jQuery UI widget asset bundle, initializes it with client options and registers related events yii\jui\Widget

Property Details

$clientEventMap protected property

Event names mapped to what should be specified in .on(). If empty, it is assumed that event passed to clientEvents is prefixed with widget name.

protected array $clientEventMap = ['activate' => 'sortactivate''beforeStop' => 'sortbeforestop''change' => 'sortchange''create' => 'sortcreate''deactivate' => 'sortdeactivate''out' => 'sortout''over' => 'sortover''receive' => 'sortreceive''remove' => 'sortremove''sort' => 'sort''start' => 'sortstart''stop' => 'sortstop''update' => 'sortupdate']
$itemOptions public property

List of HTML attributes for the item container tags. This will be overwritten by the "options" set in individual $items. The following special options are recognized:

  • tag: string, defaults to "li", the tag name of the item container tags.

See also \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.

public array $itemOptions = []
$items public property

List of sortable items. Each item can be a string representing the item content or an array of the following structure:

[
    'content' => 'item content',
    // the HTML attributes of the item container tag. This will overwrite "itemOptions".
    'options' => [],
]
public array $items = []
$options public property

The HTML attributes for the widget container tag. The following special options are recognized:

  • tag: string, defaults to "ul", the tag name of the container tag of this widget.

See also \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.

public array $options = []

Method Details

renderItems() public method

Renders sortable items as specified on $items.

public string renderItems ( )
return string

The rendering result.

throws \yii\jui\InvalidConfigException.
run() public method

Renders the widget.

public void run ( )