jQWidgets Forums
jQuery UI Widgets › Forums › Navigation › Tree › dragEnd event mistake
This topic contains 5 replies, has 2 voices, and was last updated by Dimitar 12 years, 7 months ago.
-
AuthordragEnd event mistake Posts
-
Hi
i have a page with 2 jqxTree. Both tree load json data from server.
One of this tree has a bind on dragEnd event. When dragEnd event called the “event” parameter of function refer other tree.
How it’s possible? Can’t i have more than one tree on the same page?
Thanks
Hello marchip,
We were not able to reproduce the reported behaviour. Could you, please, provide us with a code snippet which includes the event binding?
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/<script type="text/javascript"> var theme = 'classic'; $(document).ready(function () { var onTreeField = false; loadFields(); loadCustom(); loadFunctions(); $("#jqxTreeEvent").bind('dragEnd', function (event, source) { if (event.args.originalEvent != undefined) { //************problem is here************ //this event parameter refer jqxTreeFunction instead #jqxTreeEvent //my code.... } }); }); function loadFields() { var xmlEvent = getXmlEvent(); var treeSource = { localdata: xmlEvent, datatype: 'json' }; var dataAdapter = new $.jqx.dataAdapter(treeSource); dataAdapter.dataBind(); var records = dataAdapter.getRecordsHierarchy('id', 'parentId', 'items', [{ name: 'text', map: 'label' }, { name: 'tag', map: 'value'}]); $('#jqxTreeEvent').jqxTree({ source: records, width: '300px', theme: 'classic', allowDrag: true, allowDrop: false }); } function loadCustom() { $('#jqxTreeField').jqxTree({ height: '250px', width: '200px', theme: theme, allowDrop: true }); } function loadFunctions() { $.ajax({ url: "/Event/GetFunctions", type: "GET", beforeSend: function () { }, error: function (json, textStatus, errorThrown) { }, success: function (data2) { var treeSource2 = { localdata: data2, datatype: 'json' }; var dataAdapter2 = new $.jqx.dataAdapter(treeSource2); dataAdapter2.dataBind(); var records2 = dataAdapter2.getRecordsHierarchy('id', 'parentId', 'items', [{ name: 'signature', map: 'label' }, { name: 'type', map: 'value'}]); $('#jqxTreeFunction').jqxTree({ source: records2, width: '200px', height: '250px', theme: 'classic', allowDrop: false }); $('#jqxTreeFunction').jqxTree('expandAll'); } }); }</script><div id='jqxWidget'> <div style='float: left;'> <div id='jqxTreeEvent' style='float: left; margin-left: 0px;'> </div> <div style='float: left; margin-left: 20px;' id="jqxTreeField"> </div> </div><br /><br /><br /> <div style='margin-left: 20px;' id="jqxTreeFunction"> </div></div>
Hi marchip,
The value of event.args.originalEvent.type is “mouseup” and it does not refer to any specific jqxTree. To see which tree calls the event, use the value of event.target.id – it shows the id of the tree from which you take an element.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Ok.
But also event.args.label refer to jqxTreeFunction instead jqxTreeField. It’s normal??
If is normal I can take the value of element that i have dropped?Thanks
Hi marchip,
The value of the dropped element is that of event.args.label.
For more information, please check out the documentation on dragStart and dragEnd in jqxTree’s API.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.