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
Item callback "drop" firing event ignoring the "dragTo" board values #22
Comments
Hi @jhonatanjunio can you post an example of your code? |
Of course! Here you go!
This is running under an Ajax call that collect items from database to fill the boards, based on their statuses. I simplified the names I used (which it was in portuguese) to a close approach, focusing on the
Thanks in advance, @riktar ! |
Hi @jhonatanjunio. |
Nice, @riktar ! I really appreciate that. Again, thanks and congrats for the amazing work! |
I had that issue either. Unlikely dragula fires the drop event even when we had set dragTo attribute. |
@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!");
}
});
}
}); |
Thanks, @marcosrocha85 ! This solved my problem. Regards, |
When I set the
dragTo
value to a board, theitem
callbackdrop
is ignoringdragTo
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: thedrop
callback is firing this$.ajax
dispite of the board limitations (which is visually showing that the dropping are not allowed in certain boards), changing theitem
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
The text was updated successfully, but these errors were encountered: