angular-sortable-view icon indicating copy to clipboard operation
angular-sortable-view copied to clipboard

Nested sv-handle doesn't work

Open mrft opened this issue 9 years ago • 2 comments

When you have something similar to this structure:

<div sv-root="tasks-sv" sv-part="questionTasks">
    <div sv-element ng-repeat="task in questionTasks track by $index">
        {{task.description}}
        <!-- handle for reordering tasks-->
        <button sv-handle class="btn btn-warning btn-sm" tabindex="-1"><span class="glyphicon glyphicon-sort"></span></button>
        <!-- inside of every 'task', we have something to edit this task, and we'd like to use sv there also -->
        <div sv-root="options-$index" sv-part="task.options">
            <div sv-element ng-repeat="option in task.options track by $index">
                {{option.name}}
                <!-- handle for reordering options within a task -->
                <button sv-handle class="btn btn-warning btn-sm" tabindex="-1"><span class="glyphicon glyphicon-sort"></span></button>
            </div>
        </div>
   </div>
</div>

All of the sv-handles will reorder the outmost sortable.

I guess it should be possible to allow for either sv-handle="id", to make sure that the sv-handle knows to which sv it is linked, or that sv-handle only sorts the closest sv-root (when going 'up' in the tree).

Also, it doesn't seem to matter if I put that 'inner' editor inside of a new angular directive (I thought, if I create a new directive then it will probably work, but apparently it doesn't).

mrft avatar Jul 08 '15 09:07 mrft

@mrft, I also use a similar code for the ng-repeat, and i've found out that the "track by $index" is causing sv to not reorder OR to be sortable.
I know that it's not a proper solution, however can you try removing the "track by" - and confirm this? btw, @kamilkp ,same issue described in ui-sortable - https://github.com/angular-ui/ui-sortable/issues/354

orizens avatar Oct 08 '15 14:10 orizens

Well,

I am happily using https://github.com/angular-ui/ui-sortable now, and everything works as expected.

So I couldn't say what would happen removing 'track by'.

2015-10-08 16:42 GMT+02:00 Oren Farhi [email protected]:

@mrft https://github.com/mrft, I also use a similar code for the ng-repeat, and i've found out that the "track by $index" is causing sv to not reorder OR to be sortable.

I know that it's not a proper solution, however can you try removing the "track by" - and confirm this? @kamilkp https://github.com/kamilkp fyi

— Reply to this email directly or view it on GitHub https://github.com/kamilkp/angular-sortable-view/issues/58#issuecomment-146567036 .

mrft avatar Oct 11 '15 19:10 mrft