jQWidgets Forums

jQuery UI Widgets Forums Navigation Tree dragEnd event mistake

Tagged: , ,

This topic contains 5 replies, has 2 voices, and was last updated by  Dimitar 12 years, 7 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • dragEnd event mistake #10735

    marchip
    Member

    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

    dragEnd event mistake #10767

    Dimitar
    Participant

    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,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    dragEnd event mistake #10773

    marchip
    Member
    <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>
    dragEnd event mistake #10774

    Dimitar
    Participant

    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,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    dragEnd event mistake #10777

    marchip
    Member

    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

    dragEnd event mistake #10778

    Dimitar
    Participant

    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,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.