jstree stable version: How do I check if there are any children before refreshing the tree?

StackOverflow https://stackoverflow.com/questions/10940326

質問

I want only to refresh the tree if there are no children.. ie:

    $.jstree._reference("#f").get_checked(-1, true).each(function(index,element)
    {
    $("f").jstree("remove",'#'+$(element).attr("id"));  
    });


    $.jstree._reference($("#{$id[$k]}")).refresh(-1);   

right now this triggers refreshing the tree every time that I finish removing nodes with the checkbox plugin, but I wish that I didn't need to see the loading every time, but only if there is no nodes... when that happens a table gets recreated so I just need to worry about triggering the event when that happens.

Any assistance would be very welcomed!

Thanks ,

JP-

役に立ちましたか?

解決

        <?
        case "remove":
                    $.jstree._reference("#{$id[$k]}").get_checked(-1, true).each(function(index,element){
                    $("#{$id[$k]}").jstree("remove",'#'+$(element).attr("id"));     

                    // only refresh if we are taking the first node displayed... it's going to recreate it in the backend.
                        if( $(element).attr("id") ==  $("div.jstree > ul > li").first().attr("id") )
                        { 
                        $.jstree._reference($("#{$id[$k]}")).refresh(-1);           
                        }

                    });
        break;

        ?>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top