-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reordering of menu items after adding a new one #9
Comments
After edit, also issue exist. |
Yep, I've just come across this issue too. |
Update <?= $this->makePartial('toolbar') ?>
<p class="help-block before-field"><br>Drag and drop the menu items using the icons on the left. Click a menu item to edit it.</p>
<div class="form-preview">
<div
id="itemTreeList"
class="control-treelist"
data-control="treelist"
data-handle="a.move"
data-stripe-load-indicator>
<ol id="reorderRecords">
<?php
if ($value->count()) {
echo $this->makePartial('itemrecords', [
'records' => $value
]);
} else {
?>
<li>Go on spoilt yourself, add some menu items.</li>
<?php
}
?>
</ol>
</div>
</div>
<script>
/**
* Initialise Tree List Widget Move Handler.
*
* @return {void}
*/
function initialiseTreeListWidgetMoveHandler() {
$('#itemTreeList').on('move.oc.treelist', function(ev, data) {
var $el,
$item = data.item,
moveData = {
sourceNode : $item.data('recordId'),
position : 'root',
targetNode : 0
};
if (($el = $item.next()) && $el.length) {
moveData.position = 'before'
} else if (($el = $item.prev()) && $el.length) {
moveData.position = 'after'
} else if (($el = $item.parents('li:first')) && $el.length) {
moveData.position = 'child'
}
if ($el.length) {
moveData.targetNode = $el.data('recordId');
}
$('#itemTreeList').request('<?=$this->getEventHandler('onMove')?>', {
data : moveData
});
});
}
/**
* Refresh Tree List Widget.
*
* @return {void}
*/
function refreshTreeListWidget() {
$('[data-control="treelist"]').treeListWidget();
initialiseTreeListWidgetMoveHandler();
}
initialiseTreeListWidgetMoveHandler();
</script> Then add the |
Create new partial file _treelist.htm in formwidgets/itemlist/partials, then move the list inside. _treelist.htm
Update itemlist.htm as follows:
Then in Rw\Menu\FormWidgets\ItemList change all returns whit the new partial tree_list old return:
new return:
|
I want to create a new menu entry.
the menu entry is shown on the buttom of the menu
The menu entry cannot be moved at the moment
Before it's possible to move the entry you have to:
Now the menu entry can be moved.
It should be possible to move the menu entry directly after inserting
(without saving and especially without reloading the page).
The text was updated successfully, but these errors were encountered: