question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Item callback "drop" firing event ignoring the "dragTo" board values

See original GitHub issue

When I set the dragTo value to a board, the item callbackdrop is ignoring dragTo possible limitations. In my project, I’m allowing the items to move through the boards one at once. It’s working fine, but when this is done, I have to change the status_id of this item I dragged to the next board. To accomplish this, I created an $.ajax to post the new id to that Item. The problem is: the drop callback is firing this $.ajax dispite of the board limitations (which is visually showing that the dropping are not allowed in certain boards), changing the item ID, which is not the expected behaviour. Can you help me with this? What can I be doing wrong on here? Sorry if this is not an Issue. Tell me if it’s not. Thanks for this amazing work!

Regards, Jhon

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jhonatanjuniocommented, Sep 28, 2018

Thanks, @marcosrocha85 ! This solved my problem. I had to remove the var new_board = target.children("header").data('board_id'); line, which was throwing the error target.children its not a function. Anyways, I sorted this out and everything is working as expected. Thanks a lot!

Regards, Jhon

1reaction
marcosrocha85commented, Sep 28, 2018

@jhonatanjunio My example of code:

jkanban = new jKanban({
    element: '#my_kanban',
    click: function(el) {
        showDialogModal(
            $(el).data("eid"), // item id
            $(el.parentElement.parentElement).data("id") // board id
        );
    },
    dropEl: function(el, target, source, sibling) {
        var allowedBoards = [];
        jkanban.options.boards.map(function (board) {
            if (board.id === $(source.parentElement).data("id")) {
                board.dragTo.map(function (_board) {
                    if (allowedBoards.indexOf(_board) === -1) {
                        allowedBoards.push(_board);
                    }
                });

                return allowedBoards[0];
            }

            return allowedBoards[0];
        });

        if (allowedBoards.length > 0 && allowedBoards.indexOf($(target.parentElement).data("id")) === -1) {
            kanban.drake.cancel(true);
            return;
        }

        var item_id = $(el).data("eid");
        var new_board = target.children("header").data('id');
        $.ajax({
            type: 'POST',
            url: 'localhost/move',
            data: {
                'item_id': item_id,
                'new_board': new_board,
            },
            cache: false,
            success: function (result) {
                console.log("It's done.");
            },
            error: function() {
                console.log("Uh oh! There's an error!");
            }
        });
    }
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

jQueryUI droppable : over and out callback firing out of ...
On an out event handle the out and set the element to null. ... And use the over event to handle all the...
Read more >
Drag operations - Web APIs | MDN
When a user begins to drag, the dragstart event is fired. In this example the dragstart listener is added to the draggable element...
Read more >
GUI Programming Part 2 - Java Programming Tutorial
JComboBox receives a Object array (typically a String array), which provides the items in the drop-down list. JComboBox fires ItemEvent .
Read more >
The Racket Graphical Interface Toolkit
Only the labels and callbacks of the menu's items are used; the enable state, submenus, or separators are ignored. (send a-combo-field on-popup event)...
Read more >
How to drag and drop data to/from the grid - AG Grid
Drag and drop is a mechanism for dragging and dropping rows to / from the data ... callbacks or firing events in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found