Jez D
Jez D

Reputation: 1489

Sencha: remove dynamically created components using CSS class

In my sencha mobile web app I have dynamically created elements/containers in my view.

Each has a uniquie id but all same the same css class.

I am trying to find a way to remove them using the css class. The reason I need to use the css class and not the id is that the number created cannot be determined at runtime.

I have tried Ext.select('.myContainer').remove(); but that give error "has no method 'remove' "

I also tried
var main = Ext.getCmp('mainpage');
main.remove(main.down('.siteContainer'));

but that did nothing at all.

I'm still new to Sencha. Any advice would be very much appreciated.

I was hoping for something similar to jquery's $('.classname').remove() which will work on multiple elements at the same time.

Upvotes: 0

Views: 1512

Answers (2)

Jez D
Jez D

Reputation: 1489

I solved it by using jquery to get the ID of each component with the same class, then used senchas destroy() on the acquired ID.

$( $('.siteContainer') ).each(function( index ) {
var thiscont = $(this).attr('id');
Ext.getCmp(thiscont).destroy();
});

Upvotes: 0

Nico Grunfeld
Nico Grunfeld

Reputation: 1133

Did you try with removeNode or with destroy ?

Upvotes: 1

Related Questions