admin管理员组文章数量:1420145
I have created this
/
jQuery(function($) {
$(document).on('dnd_stop.vakata', function(e, data) {
var origin = $(data.element);
var target = $(data.event.target);
// Missing something here to get if the origin is before or after the target
$('#result').html(
'<div><b>Target:</b> ' + target.html() + '</div>' +
'<div><b>Origin:</b> ' + origin.html() + '</div>'
);
})
$('#jstree_demo').jstree({
"core" : {
"check_callback" : true,
"themes" : { "stripes" : true },
},
"plugins" : [
"dnd"
]
});
});
Now if I move fx 1-5 to the top, the target is 1-1 but if I move fx 1-5 to the bottom, the target is 1-8
Is there any method where I can find out if the origin is before or after the target?
I have created this
http://jsfiddle/n82vvvo6/
jQuery(function($) {
$(document).on('dnd_stop.vakata', function(e, data) {
var origin = $(data.element);
var target = $(data.event.target);
// Missing something here to get if the origin is before or after the target
$('#result').html(
'<div><b>Target:</b> ' + target.html() + '</div>' +
'<div><b>Origin:</b> ' + origin.html() + '</div>'
);
})
$('#jstree_demo').jstree({
"core" : {
"check_callback" : true,
"themes" : { "stripes" : true },
},
"plugins" : [
"dnd"
]
});
});
Now if I move fx 1-5 to the top, the target is 1-1 but if I move fx 1-5 to the bottom, the target is 1-8
Is there any method where I can find out if the origin is before or after the target?
Share Improve this question asked Dec 3, 2014 at 13:16 Martin-Martin- 9272 gold badges13 silver badges30 bronze badges1 Answer
Reset to default 5This may be a little different then your direct question but this is how I solved the issue of figuring out the position of the drop. After the 'dnd_stop.vakata' is called the 'move_node.jstree' event is called which does contain the item being moved, old parent, new parent, and index point the item is to be dropped.
$('#AdminTree').on("move_node.jstree", function (e, data) {
//item being moved
var moveitemID = $('#' + data.node.id).find('a')[0].id;
//new parent
var newParentID = $('#' + data.parent).find('a')[0].id;
//old parent
var oldParentID = $('#' + data.old_parent).find('a')[0].id;
//position index point in group
//old position
var oldPostionIndex = data.old_position;
//new position
var newPostionIndex = data.position;
});
本文标签: javascriptjstree 3 get the position where the target got droppedStack Overflow
版权声明:本文标题:javascript - jstree 3 get the position where the target got dropped - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745324146a2653513.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论