Empty a Window

You must Login before you can answer or comment on any questions.

Hi,

I have a window that contains six buttons, each button has a Click event that fills a window named products, this six products are displayed depending on the button pressed. My problem is that when I return to the window of the six main buttons and click another button displayed last six products plus six new products. How I can avoid that? I used win.remove or win.close and keeps everything seen, window not is cleaned.

3 Answers

Accepted Answer

As long as you're closing the product window and opening a new one each time, then you shouldn't have any issues.

— answered 8 months ago by Anthony Decena
answer permalink
5 Comments
  • yes, I have no problem, but when I re-enter the previous one it cleans the product

    — commented 8 months ago by Juan Segura

  • doesn't cleans...

    — commented 8 months ago by Juan Segura

  • You shouldn't have to clean, it should be a brand new, fresh, unbuilt, unused, unconstructed window.

    — commented 8 months ago by Anthony Decena

  • Show 2 more comments

Are u using commonJS? that can help you. Sometimes when some object is linked in the global scope, the garbage collector cant take those resources and they stay alive... check memory leak docs and videos for that.

function removeChildrens(objeto) {
    for (i in objeto.children) {
        var child=objeto.children[0];
        removeChildrens(child);
        objeto.remove(child);
        child=null;
    }
}
fix it

— answered 8 months ago by Juan Segura
answer permalink
1 Comment
  • If you are using commonjs properly as you say, this should not be necessary. The problem with this is if you reference one of those child elements outside of this scope, even though the child is removed, the reference will remain in memory, along with any children of that reference. Use with caution.

    — commented 8 months ago by Anthony Decena

Your Answer

Think you can help? Login to answer this question!