jQWidgets Forums
jQuery UI Widgets › Forums › Navigation › Tree › Different event signatures for dragEnd event
Tagged: javascript tree, jquery tree, jqxtree, Tree
This topic contains 6 replies, has 4 voices, and was last updated by Peter Stoev 10 years, 5 months ago.
-
Author
-
I’m looking at the following example:
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxtree/dragdrop.htm?classic
Looking at line 31, the jqxTree is initialized with the following code:
$('#treeB').jqxTree({ allowDrag: true, allowDrop: true, height: '300px', width: '220px', theme: theme, dragEnd: function (item, dropItem, args, dropPosition, tree) { if (item.label == "Forum") return false; }});
Later, around line 41, the dragEnd event handler is attached via the bind method:
$("#treeA, #treeB").bind('dragEnd', function (event) {
The two event handler signatures are different and I’m wondering why. Is there a preferred version to use? I would think the first one since it provides more data about the drag operation.
Thanks.
Hi psteele,
There is an event called dragEnd event. There is also a dragEnd function. You can take a look at the help docs: jquery-tree-api.htm. You can use either the event or the function depending on your application’s logic and whether event bubbling and additional information which it brings as an event is important for you.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comAh, I see. Thanks Peter!
Out of curiosity, which one is called first — the function or the event? Or is it indeterminate?
Hi psteele,
The function is called first because it can be used for cancelling the drop.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comBoth seem useful:
dragEnd function: To determine whether a drag is allowable before the drag is completed, and even before asking the user to confirm
dragEnd event: To finalize and persist the operation after the user has confirmed and the drag/drop is confirmed completed, and for other components to appropriately reflect the change.How might one get the following info available as args to the first function, from the ‘event’ argument to the second?
* item -> event.args.originalEvent.element
* dropItem -> ?
* dropPosition (‘before’, ‘inside’, ‘after’) -> ?me too have the same problem gradulastudent.
have you solved this problem?Hi azad,
The events and callbacks are different and their API is documented. You can use them in the way described in the Tree’s API documentation.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.