English 中文(简体)
Remove a Sencha Touch 2 component
原标题:

What is the correct way of removing a component I know I m not going to use anymore, but I want to use new instances of the same class later?

For example, a create form is added to the viewport using Ext.Viewport.add(), but once it is submitted, I want to destroy the form, so next time the user wants to create an item, a new form is generated (i.e. new component is instantiated).

I tried both Ext.Viewport.remove(form, false) and Ext.Viewport.remove(form, true), they both give me errors: TypeError: Cannot set property className of undefined.

最佳回答

Apparently, the reason this was not working is that I have tried to remove a component from code that I ran from an event handler for a component contained in the component to-be-removed.

Example, if you click on a button, and the button immediately tries to remove its container component from the viewport, the remove will succeed, but the button release event will be called with no DOM element to work with, as the button itself has also been removed.

An easy workaround is to call Ext.Viewport.remove(...) after a short timeout.

问题回答

暂无回答




相关问题
How to use JSON without json file?

I need to use dynamically JSON with data.TreeStore. With this component, there is proxy "config", it need a path to JSON file. My problem is, i can t write Json file in my application. I would know, ...

Dynamic Model with ExtJS 4

With ExtJS 3.x, I was able to use the "fields" property of a Store, but it seems with ExtJS 4 I have to absolutely use a Model. It s fine, but in my case, it s not a static Model, and I need to define ...

TreeNode click event on ExtJs 4

I m using ExtJS 4 (beta 3) and I have a TreePanel that is my kind of navigation menu. It is something like this: Jobs Add Job List All Jobs ... ... ... (this will be made on a permission system ...

Ext.loader not enabled Missing required?

I have some problems with Extjs4 librairie. I want to use treeEditor component. Firebug error : Error : uncaught exception: Ext.Loader is not enabled, so dependencies cannot be resolved ...

how to make a "MVC Application" with extjs 4.0 beta 3?

Is there someone here who made a MVC application using EXTJS 4 BETA 3? and works fine?? please help me how?, .. I have followed step by step here .. and @Abdel Olakara help but there is still an ...

Object function has no method defer

I m try to render a progress bar in grid (Ext JS), and get this error: Object function has no method defer What is this "magical" method? What does it do? And why is it not found? Code: renderer:...

热门标签