What does this function means.

contentEl : 'av',

thanks!

Dani AI

Generated

Building on and , here are practical, safe ways to put the element back when the popup closes. The idea is to record where the element lived before the popup grabbed it, then move it back before the popup/panel is destroyed. That avoids losing the node or its handlers.

A simple, robust approach: save the original parent and next sibling before opening the popup, then restore the DOM node in the popup's close handler. This uses only standard DOM APIs so it works across Ext versions:

var el = Ext.getDom('av');           // original element
var origParent = el.parentNode;
var origNext = el.nextSibling;

// create popup/panel with contentEl: 'av' ...
// in the popup/window:
listeners: {
  beforeclose: function(win) {
    if (origNext && origNext.parentNode === origParent) {
      origParent.insertBefore(el, origNext);
    } else {
      origParent.appendChild(el);
    }
    // allow the close to continue
  }
}

Alternatives and gotchas:

  • If you only need the HTML, copy el.innerHTML into the panel (or use panel.update() / setHtml()), then restore the HTML string on close. That does not preserve event listeners bound to the original DOM nodes.
  • If you must preserve handlers attached to the actual node, move the original node back (do not clone).
  • Always restore before the panel/window is destroyed. Use beforeclose (or the earliest close hook your Ext version provides) so you can reinsert the node before cleanup runs.
  • If layout/spacing matters while the node is in the popup, create a small placeholder element at the original spot and replace it when restoring.

These steps keep the DOM intact and avoid accidental loss of elements or handlers when transferring content into and out of a popup.

Recommended Answers

All 2 Replies

It is not a function and on its own it means nothing.

The only thing similar to this, is when I set the data option when making an ajax call with jQuery.

http://malsup.com/jquery/form/

Thanks javaAddict , I google this topic and it says

•renderTo renders the Component into the specified existing element.

•applyTo uses the specified alement as the main elementof the Component. A Component created using applyTo does not need rendering - its main element already exists.

contentEl is only for Panels. It simply moves the specified element into the body of the Panel when the Panel is rendered to use... as the content!


Im currently using contentEl to transfer the content of the panel to a popup window, now my problem is how to transfer it back when I close the popup window :(

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.