$('#tree_content_div').treeControl( { // root : 'top' // callback, "" , name : function( obj ){ return obj.name; } // CSS , theme : 'custom' // callback, messages , info : function( data ){ alert(data); } // , animate : 1500 // , preloader : 2 // , classes : { treeLeaf : 'tree-leaf' , heading : 'heading' , control : 'control' , status : 'status' , loader : 'loader' , selected : 'selected' , preloader : 'preloader' , hover : 'hover' } // , control : { text : ['+', '–'], cls : 'open' } // $.tmpl() , template : '<li><span class = "heading">${obj.name}</span> <ul class = "tree-leaf"></ul></li>' // +\- $.tmpl() , ctrlTpl : '<span class = "control"></span>' // "" $.tmpl() , statusTpl : '<span class = "status"></span>' // bind , , // , , handlers : { control : function( leaf ){ } , select : function( leaf ){ } , blur : function( leaf , result ){ if (something){ // Your Great Checking / Blocking code }else{ result(); } } , leafsAdd : function( leaf , controlObject ){ } } // bind ... , callbacks { click : function( leaf ){ } , mouseover : function( leaf ){ } , mouseout : function( leaf ){ } } // , $.cookie // saveState -- , saveState : { name : 'tree_control_cookie_name' , opts : { expires: 150 } } // -- , , : , ws : function( val, callback ){ try{ var val = ( typeof( val ) == 'string' ) ? { 'leaf' : val , action : 'get' } : ( ( typeof( val ) == 'object' ) ? val : false ); if( val ){ $.ajax( { type: "POST" , async: true , data : val , dataType : 'text' , url: './tree.php' , success: function( data ){ if( data !== ''){ callback( data ); } } , error: function(data){ alert(data); } } ) ; } }catch(e){ alert(e); } } } );
/* { name : 'leaf.name from JSON received through 'ws', eg ID' obj : { name : ' returned by x.name( leaf ) ' , children : ' array of leafs that are children of this ' , parent : 'link to parent' , obj : 'JSON that comes from ws' , elem : { li : DOM of this leaf's LI , ul : DOM of this leaf's UL (where children are) , heading : DOM of heading span , control : DOM of control span , status : DOM of status span } } } */
Source: https://habr.com/ru/post/142603/
All Articles