1. #1
    Sencha Premium Member Zdeno's Avatar
    Join Date
    Nov 2009
    Location
    Prague
    Posts
    389
    Answers
    7
    Vote Rating
    17
    Zdeno will become famous soon enough

      0  

    Default Unanswered: Why did you use appendChild function inside insertChild?

    Unanswered: Why did you use appendChild function inside insertChild?


    When you check source code of function insertChild, you will find following code:

    Code:
    insertChild: function(index, node) {
        var sibling = this.childNodes[index];
        if (sibling) {
            return this.insertBefore(node, sibling);
        }
        else {
            return this.appendChild(node);
        }
    },
    Why did you use appendChild function when sibling does not exists? Instead of appendChild you have to check count of childNodes and then you can say if you want put node to childNodes or you have to call appendChild. AppendChild will add node at the end of array but i wanted insert node to specific index. Thats why i used insertChild instead of appendChild.

  2. #2
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,114
    Answers
    83
    Vote Rating
    30
    tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about

      0  

    Default


    I do not understand your question. If there are no siblings or the position in the input doesn't return a sibling, then the node is added at the end.

    That what is written in the function.

    If siblingnode by index is found
    then insert node before that sibling
    Else
    insert at end

    Is correct I think

Thread Participants: 1

Tags for this Thread