Element insert before: fetch elements that has been added using insertAfter

57 Views Asked by At

In my application we are using tree structure and on each click of + ( expand) ajax call is triggered which renders its respective child elements using Element.insert ( prototype.js) Now i need to have this element using .children() . but i dont receive it

To insert child elements on + we use below

var Insertion = {
  Before: function(element, content) {
    return Element.insert(element, {before:content});
  },

  Top: function(element, content) {
    return Element.insert(element, {top:content});
  },
    Bottom: function(element, content) {
       
            
        return Element.insert(element, {bottom:content});
      }
}

Now when i try to find child of parent node, i did not receive this newly added node content

for example below is my ul li

    <ul class="list">
   <li class="node minus" id="node_7361">
      <a href="#" class="node activeNode" id="parentLabel">XXX</a>
      <span class="informal" style="display: none;">
      </span>
      <ul class="qualificationList">
         <li></li>
      </ul>
   </li>
</ul>

Now when i try to find children using $('.list > li').children() i get only first two child( a and span) and not third one(ul), as this added using Element.insert Note : <li> has three child above

1

There are 1 best solutions below

1
Geek Num 88 On

Based on your comment, you are using $('.list > li').children() to get all the children, which is called through jQuery. Have you tried using the PrototypeJS method and see what results you get? I've had issues in the past where PrototypeJS directly updates the DOM, but method calls immediately after using jQuery don't see the DOM updates because of some issue (I guessed DOM/CSS caching but I could be wrong).

So try getting the list of child elements with $$('.list > li').first().childElements() ?