-
19 Mar 2012 8:26 AM #1
Answered: dom exception 8 when i try to istantiate again a new carousel
Answered: dom exception 8 when i try to istantiate again a new carousel
Hi all,
i define the carosuel this way :
Ext.define('HelloWorld.Modella1', {
extend: 'Ext.Carousel',
cls: 'carmod1',
alias: 'widget.modella1',
initialize: function() {
this.add([{
xtype: 'toolbar',
docked: 'top',
title: 'Models',
items: backButton
},
{
html: '<img src="resources/stockings/models/img01.jpg" />'
},
{
html: '<img src="resources/stockings/models/img02.jpg" />'
}
......
this is the handler of the back button which destroy the carousel:
if(Ext.ComponentQuery.query('modella1')[0])
Ext.Vievport.remove(Ext.ComponentQuery.query('modella1')[0], true);
then if(!Ext.ComponentQuery.query('modella1')[0]){
Ext.Viewport.add(new HelloWorld.Modella1().show());
}
else {
Ext.ComponentQuery.query('modella1')[0].show();
}
the first time it's ok and a new istance of Modella is correctly displayed .
Pressing the back button it is correctly destroyed but when i try the second new HelloWorld.Modella1() i get the dom error.
I've tried different solutions but i cant find a solution to create a new istance of the same carosuel when previously destroyed (i had a similar problem with sencha touch 1, i solved the problem putting the all configs in the init function).
Thanks in advance.
-
Best Answer Posted by mitchellsimoens
Is there something in the HelloWorld.Modella1 class that is being created outside the class?
-
19 Mar 2012 11:09 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
- Answers
- 3105
When you remove a component, it is destroyed. You can do one of two things... create a new carousel instance every time you try to add it or set autoDestroy to false on the carousel.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
19 Mar 2012 11:27 AM #3
Hi Mitchell,
thank you for the response.
I would like to create a new instance but as soon as i destroy the first a cant create a new one.
Eg.
Ext.Viewport.add(HelloWorld.Modella1().show) // first time ok
Ext.Viewport.remove(Ext.ComponentQuery.query('modella1')) //destoyed ok, there's a listener on destroy event
Ext.Viewport.add(HelloWorld.Modella1().show) // Error with Dom exception 8
I've also tried getCmp() with the id of the carousel but still nothing.
Bye
-
19 Mar 2012 11:30 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
- Answers
- 3105
What is HelloWorld.Modella1?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
19 Mar 2012 11:37 AM #5
It is a carousel class :
var my model = new HelloWorld.Modella1(); // it's ok
Ext.define('HelloWorld.Modella1', {
extend: 'Ext.Carousel',
cls: 'carmod1',
alias: 'widget.modella1',
initialize: function() {
this.add([{
xtype: 'toolbar',
docked: 'top',
title: 'Models',
items: backButton
},
{
html: '<img src="resources/stockings/models/img01.jpg" />'
},
{
html: '<img src="resources/stockings/models/img02.jpg" />'
}
etc
-
19 Mar 2012 11:38 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
- Answers
- 3105
Ok, then this:
should be:Code:Ext.Viewport.add(HelloWorld.Modella1().show);
Code:Ext.Viewport.add(new HelloWorld.Modella1());
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
19 Mar 2012 11:51 AM #7
Sorry, i made a typo in the last reply, my bad, in the first post i wrote it correctly:
Ext.Viewport.add(new HelloWorld.Modella1()) // this gives the error the second time it is executed
If the problem is not clear i could post a test case extracting the code from the context.
Thank you
-
19 Mar 2012 12:15 PM #8Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
- Answers
- 3105
Is there something in the HelloWorld.Modella1 class that is being created outside the class?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
19 Mar 2012 12:43 PM #9
This is the class (i deleted listeners and some items and still get the error) im trying with :
Ext.define('HelloWorld.Modella1', {
extend: 'Ext.Carousel',
id: 'modella1',
initialize: function() {
this.add([{
xtype: 'toolbar',
docked: 'top',
title: 'Models',
items: backButton
},
{
html: '<img src="resources/stockings/models/lehotska/01.jpg" />'
},
{
html: '<img src="resources/stockings/models/lehotska/02.jpg" />'
}
]);
this.callParent();
}
});
-
19 Mar 2012 2:09 PM #10
Thank you Mitchell !
I was creating the back button outside carousel, i just moved it inside initialize function and now the class works as intended.


Reply With Quote