riktar / jkanban

Vanilla Javascript plugin for manage kanban boards
https://www.riccardotartaglia.it/jkanban/
Apache License 2.0
1.07k stars 297 forks source link

Get the board order to update in db #54

Closed akramwahid closed 5 years ago

akramwahid commented 5 years ago

Can you please help to get the board orders in the event when a board is dragged around, dragBoard : function (el, source) {}, I know we can use this listener to detect the movement, but how to get the new order to pass to server

akramwahid commented 5 years ago

I did it my self like this way, but if there is an easy-way than this please let me know, thanks,

dragendBoard: function (el) {
                        var boardIds = $('.kanban-board').map(function(){
                            return $(this).attr("data-id")
                        }).get();

                        var sorted = [];
                        var currentOrder = 0;
                        boardIds.forEach(function(value, index, array) {
                            sorted.push({
                                "id": value,
                                "order": currentOrder++
                            })
                        });
                        console.log(JSON.stringify(sorted));
                    }