jQWidgets Forums

jQuery UI Widgets Forums Navigation Tree expandItem sometimes not working immediately after addTo

This topic contains 1 reply, has 2 voices, and was last updated by  svetoslav_borislavov 2 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • Gary
    Participant

    I’m encountering an issue with expandItem toggling the arrow of the branch, but leaving the child nodes hidden.

    http://jsfiddle.net/GaryGen/cx4ruj9a/10/

    I can work around this by putting a delay on the expandItem using a timer, but it should probably be addressed at some point.

       $('#jqxTree').jqxTree({
           height: '300px',
           width: '300px',
           theme: 'energyblue' 
       });
       $('#jqxTree').jqxTree('addTo', {id:'preTop', label:"Pre-Top"});
       $('#jqxTree').jqxTree('addTo', {id:'treeTop', label:"Top"});
       let treeTop = document.getElementById('treeTop');
       $('#jqxTree').jqxTree('addTo', {id:'branchA', label:"A"}, treeTop);
       $('#jqxTree').jqxTree('addTo', {id:'branchB', label:"B"}, treeTop);
       $('#jqxTree').jqxTree('expandItem', treeTop); // This expandItem typically fails to show children.
       /*
       let expandTimer = null;
       expandTimer = setTimeout(function() {
       	 $('#jqxTree').jqxTree('expandItem', treeTop); // This expandItem always shows the children.
         clearTimeout(expandTimer);
       })
       */
       $('#jqxTree').jqxTree('addTo', {id:'postTop', label:"Post-Top"});
     

    Hi,

    This is happening because addTo is an async method and you should await the addition.
    Here is an example of doing it: http://jsfiddle.net/tjau5gbo/1/

    Best regards,
    Svetoslav Borislavov

    jQWidgets Team
    https://www.jqwidgets.com/

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

You must be logged in to reply to this topic.