Commit b6944f80 by Carsten Brandt

fixed Jui sortable clientEvents naming

fixes #2514
parent 26717e3e
......@@ -4,7 +4,8 @@ Yii Framework 2 jui extension Change Log
2.0.0 beta under development
----------------------------
- Bug #1550: fixed the issue that JUI input widgets did not property input IDs.
- Bug #1550: fixed the issue that JUI input widgets did not property input IDs. (qiangxue)
- Bug #2514: Jui sortable clientEvents were not working because of wrong naming assumptions. (cebe)
2.0.0 alpha, December 1, 2013
-----------------------------
......
......@@ -29,7 +29,7 @@ use yii\helpers\Html;
* 'options' => ['tag' => 'ul'],
* 'itemOptions' => ['tag' => 'li'],
* 'clientOptions' => ['cursor' => 'move'],
* ));
* ]);
* ```
*
* @see http://api.jqueryui.com/sortable/
......@@ -65,6 +65,25 @@ class Sortable extends Widget
*/
public $itemOptions = [];
/**
* @inheritDoc
*/
protected $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',
];
/**
* Renders the widget.
......
......@@ -38,6 +38,16 @@ class Widget extends \yii\base\Widget
* Please refer to the corresponding jQuery UI widget Web page for possible events.
* For example, [this page](http://api.jqueryui.com/accordion/) shows
* how to use the "Accordion" widget and the supported events (e.g. "create").
* Keys are the event names and values are javascript code that is passed to the `.on()` function
* as the event handler.
*
* For example you could write the following in your widget configuration:
*
* ```php
* 'clientEvents' => [
* 'change' => 'function() { alert('event "change" occured.'); }'
* ],
* ```
*/
public $clientEvents = [];
......@@ -47,6 +57,7 @@ class Widget extends \yii\base\Widget
*/
protected $clientEventMap = [];
/**
* Initializes the widget.
* If you override this method, make sure you call the parent implementation first.
......@@ -99,7 +110,7 @@ class Widget extends \yii\base\Widget
if (isset($this->clientEventMap[$event])) {
$eventName = $this->clientEventMap[$event];
} else {
$eventName = $name.$event;
$eventName = strtolower($name . $event);
}
$js[] = "jQuery('#$id').on('$eventName', $handler);";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment