function (obj, position, js, callback, is_loaded) {
        obj = this._get_node(obj);
        position = typeof position === "undefined" ? "last" : position;
        var d = $("<li>"),
          s = this._get_settings().core,
          tmp;

        if(obj !== -1 && !obj.length) { return false; }
        if(!is_loaded && !this._is_loaded(obj)) { this.load_node(obj, function () { this.create_node(obj, position, js, callback, true); }); return false; }

        this.__rollback();

        if(typeof js === "string") { js = { "data" : js }; }
        if(!js) { js = {}; }
        if(js.attr) { d.attr(js.attr); }
        if(js.state) { d.addClass("jstree-" + js.state); }
        if(!js.data) { js.data = s.strings.new_node; }
        if(!$.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); }
        $.each(js.data, function (i, m) {
          tmp = $("<a>");
          if($.isFunction(m)) { m = m.call(this, js); }
          if(typeof m == "string") { tmp.attr('href','#')[ s.html_titles ? "html" : "text" ](m); }
          else {
            if(!m.attr) { m.attr = {}; }
            if(!m.attr.href) { m.attr.href = '#'; }
            tmp.attr(m.attr)[ s.html_titles ? "html" : "text" ](m.title);
            if(m.language) { tmp.addClass(m.language); }
          }
          tmp.prepend("<ins class='jstree-icon'>&#160;</ins>");
          if(m.icon) { 
            if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); }
            else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); }
          }
          d.append(tmp);
        });
        d.prepend("<ins class='jstree-icon'>&#160;</ins>");
        if(obj === -1) {
          obj = this.get_container();
          if(position === "before") { position = "first"; }
          if(position === "after") { position = "last"; }
        }
        switch(position) {
          case "before": obj.before(d); tmp = this._get_parent(obj); break;
          case "after" : obj.after(d);  tmp = this._get_parent(obj); break;
          case "inside":
          case "first" :
            if(!obj.children("ul").length) { obj.append("<ul>"); }
            obj.children("ul").prepend(d);
            tmp = obj;
            break;
          case "last":
            if(!obj.children("ul").length) { obj.append("<ul>"); }
            obj.children("ul").append(d);
            tmp = obj;
            break;
          default:
            if(!obj.children("ul").length) { obj.append("<ul>"); }
            if(!position) { position = 0; }
            tmp = obj.children("ul").children("li").eq(position);
            if(tmp.length) { tmp.before(d); }
            else { obj.children("ul").append(d); }
            tmp = obj;
            break;
        }
        if(tmp === -1 || tmp.get(0) === this.get_container().get(0)) { tmp = -1; }
        this.clean_node(tmp);
        this.__callback({ "obj" : d, "parent" : tmp });
        if(callback) { callback.call(this, d); }
        return d;
      }
function (obj, position, js, callback, is_loaded) {
        obj = this._get_node(obj);
        position = typeof position === "undefined" ? "last" : position;
        var d = $("<li>"),
          s = this._get_settings().core,
          tmp;

        if(obj !== -1 && !obj.length) { return false; }
        if(!is_loaded && !this._is_loaded(obj)) { this.load_node(obj, function () { this.create_node(obj, position, js, callback, true); }); return false; }

        this.__rollback();

        if(typeof js === "string") { js = { "data" : js }; }
        if(!js) { js = {}; }
        if(js.attr) { d.attr(js.attr); }
        if(js.state) { d.addClass("jstree-" + js.state); }
        if(!js.data) { js.data = s.strings.new_node; }
        if(!$.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); }
        $.each(js.data, function (i, m) {
          tmp = $("<a>");
          if($.isFunction(m)) { m = m.call(this, js); }
          if(typeof m == "string") { tmp.attr('href','#')[ s.html_titles ? "html" : "text" ](m); }
          else {
            if(!m.attr) { m.attr = {}; }
            if(!m.attr.href) { m.attr.href = '#'; }
            tmp.attr(m.attr)[ s.html_titles ? "html" : "text" ](m.title);
            if(m.language) { tmp.addClass(m.language); }
          }
          tmp.prepend("<ins class='jstree-icon'>&#160;</ins>");
          if(m.icon) { 
            if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); }
            else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); }
          }
          d.append(tmp);
        });
        d.prepend("<ins class='jstree-icon'>&#160;</ins>");
        if(obj === -1) {
          obj = this.get_container();
          if(position === "before") { position = "first"; }
          if(position === "after") { position = "last"; }
        }
        switch(position) {
          case "before": obj.before(d); tmp = this._get_parent(obj); break;
          case "after" : obj.after(d);  tmp = this._get_parent(obj); break;
          case "inside":
          case "first" :
            if(!obj.children("ul").length) { obj.append("<ul>"); }
            obj.children("ul").prepend(d);
            tmp = obj;
            break;
          case "last":
            if(!obj.children("ul").length) { obj.append("<ul>"); }
            obj.children("ul").append(d);
            tmp = obj;
            break;
          default:
            if(!obj.children("ul").length) { obj.append("<ul>"); }
            if(!position) { position = 0; }
            tmp = obj.children("ul").children("li").eq(position);
            if(tmp.length) { tmp.before(d); }
            else { obj.children("ul").append(d); }
            tmp = obj;
            break;
        }
        if(tmp === -1 || tmp.get(0) === this.get_container().get(0)) { tmp = -1; }
        this.clean_node(tmp);
        this.__callback({ "obj" : d, "parent" : tmp });
        if(callback) { callback.call(this, d); }
        return d;
      }
function ( obj , position , js , callback , is_loaded ) { obj = this . _get_node ( obj ) ; position = typeof position === "undefined" ? "last" : position ; var d = $ ( "<li>" ) , s = this . _get_settings ( ) . core , tmp ; if ( obj !== - 1 && ! obj . length ) { return false ; } if ( ! is_loaded && ! this . _is_loaded ( obj ) ) { this . load_node ( obj , function ( ) { this . create_node ( obj , position , js , callback , true ) ; } ) ; return false ; } this . __rollback ( ) ; if ( typeof js === "string" ) { js = { "data" : js } ; } if ( ! js ) { js = { } ; } if ( js . attr ) { d . attr ( js . attr ) ; } if ( js . state ) { d . addClass ( "jstree-" + js . state ) ; } if ( ! js . data ) { js . data = s . strings . new_node ; } if ( ! $ . isArray ( js . data ) ) { tmp = js . data ; js . data = [ ] ; js . data . push ( tmp ) ; } $ . each ( js . data , function ( i , m ) { tmp = $ ( "<a>" ) ; if ( $ . isFunction ( m ) ) { m = m . call ( this , js ) ; } if ( typeof m == "string" ) { tmp . attr ( 'href' , '#' ) [ s . html_titles ? "html" : "text" ] ( m ) ; } else { if ( ! m . attr ) { m . attr = { } ; } if ( ! m . attr . href ) { m . attr . href = '#' ; } tmp . attr ( m . attr ) [ s . html_titles ? "html" : "text" ] ( m . title ) ; if ( m . language ) { tmp . addClass ( m . language ) ; } } tmp . prepend ( "<ins class='jstree-icon'>&#160;</ins>" ) ; if ( m . icon ) { if ( m . icon . indexOf ( "/" ) === - 1 ) { tmp . children ( "ins" ) . addClass ( m . icon ) ; } else { tmp . children ( "ins" ) . css ( "background" , "url('" + m . icon + "') center center no-repeat" ) ; } } d . append ( tmp ) ; } ) ; d . prepend ( "<ins class='jstree-icon'>&#160;</ins>" ) ; if ( obj === - 1 ) { obj = this . get_container ( ) ; if ( position === "before" ) { position = "first" ; } if ( position === "after" ) { position = "last" ; } } switch ( position ) { case "before" : obj . before ( d ) ; tmp = this . _get_parent ( obj ) ; break ; case "after" : obj . after ( d ) ; tmp = this . _get_parent ( obj ) ; break ; case "inside" : case "first" : if ( ! obj . children ( "ul" ) . length ) { obj . append ( "<ul>" ) ; } obj . children ( "ul" ) . prepend ( d ) ; tmp = obj ; break ; case "last" : if ( ! obj . children ( "ul" ) . length ) { obj . append ( "<ul>" ) ; } obj . children ( "ul" ) . append ( d ) ; tmp = obj ; break ; default : if ( ! obj . children ( "ul" ) . length ) { obj . append ( "<ul>" ) ; } if ( ! position ) { position = 0 ; } tmp = obj . children ( "ul" ) . children ( "li" ) . eq ( position ) ; if ( tmp . length ) { tmp . before ( d ) ; } else { obj . children ( "ul" ) . append ( d ) ; } tmp = obj ; break ; } if ( tmp === - 1 || tmp . get ( 0 ) === this . get_container ( ) . get ( 0 ) ) { tmp = - 1 ; } this . clean_node ( tmp ) ; this . __callback ( { "obj" : d , "parent" : tmp } ) ; if ( callback ) { callback . call ( this , d ) ; } return d ; }
Basic operations: create
Basic operations : create