a5hik/ng-sortable

confirm before dropping

Closed this issue · 1 comments

AgNm commented

I have implemented this in one of my ionic 1 project & its working totally fine. I want to add JS confirmation before I drop it in any column. If user click on "YES" then drop to specific column, if "NO" then item should go again at its previous place.

How can I achieve it?

AgNm commented

I used below code for this:

            itemMoved: function (eventObj) {
            
                var moveSuccess, moveFailure;
                /**
                 * Action to perform after move success.
                 */
                moveSuccess = function() {};
            
                /**
                 * Action to perform on move failure.
                 * remove the item from destination Column.
                 * insert the item again in original Column.
                 */
                moveFailure = function() {
                    eventObj.dest.sortableScope.removeItem(eventObj.dest.index);
                    eventObj.source.itemScope.sortableScope.insertItem(eventObj.source.index, eventObj.source.itemScope.item);
                };
            }