added onUpdate for sortable
This commit is contained in:
parent
1e54f8f753
commit
bd6223c952
|
@ -2755,6 +2755,8 @@ class htmlSortableList extends htmlElement {
|
||||||
private $id = '';
|
private $id = '';
|
||||||
/** element width */
|
/** element width */
|
||||||
private $elementWidth = '';
|
private $elementWidth = '';
|
||||||
|
/** on update event */
|
||||||
|
private $onUpdate = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -2792,9 +2794,19 @@ class htmlSortableList extends htmlElement {
|
||||||
echo '</li>';
|
echo '</li>';
|
||||||
}
|
}
|
||||||
echo '</ul>';
|
echo '</ul>';
|
||||||
|
$onUpdate = '';
|
||||||
|
if ($this->onUpdate != null) {
|
||||||
|
$onUpdate = '{
|
||||||
|
update: function(event, ui) {' . $this->onUpdate . '},
|
||||||
|
start: function(event, ui) {
|
||||||
|
var posOrig = ui.item.index();
|
||||||
|
ui.item.data(\'posOrig\', posOrig);
|
||||||
|
}
|
||||||
|
}';
|
||||||
|
}
|
||||||
$scriptContent = '
|
$scriptContent = '
|
||||||
jQuery(function() {
|
jQuery(function() {
|
||||||
$("#' . $this->id . '").sortable();
|
$("#' . $this->id . '").sortable(' . $onUpdate . ');
|
||||||
$("#' . $this->id . '").disableSelection();
|
$("#' . $this->id . '").disableSelection();
|
||||||
});';
|
});';
|
||||||
$script = new htmlJavaScript($scriptContent);
|
$script = new htmlJavaScript($scriptContent);
|
||||||
|
@ -2802,6 +2814,17 @@ class htmlSortableList extends htmlElement {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the JS code that is executed when the element order was changed.
|
||||||
|
* The code can access the variables event and ui. See JQueryUI docs for details.
|
||||||
|
* ui.item.data('posOrig') will contain the original position of the moved element.
|
||||||
|
*
|
||||||
|
* @param String $onUpdate JS code
|
||||||
|
*/
|
||||||
|
public function setOnUpdate($onUpdate) {
|
||||||
|
$this->onUpdate = $onUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue