1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    10
    Vote Rating
    0
    and cop is on a distinguished road

      0  

    Post 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.

  2. Is there something in the HelloWorld.Modella1 class that is being created outside the class?

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,525
    Vote Rating
    871
    Answers
    3564
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    10
    Vote Rating
    0
    and cop is on a distinguished road

      0  

    Default


    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

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,525
    Vote Rating
    871
    Answers
    3564
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    What is HelloWorld.Modella1?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  6. #5
    Sencha User
    Join Date
    Dec 2011
    Posts
    10
    Vote Rating
    0
    and cop is on a distinguished road

      0  

    Default


    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

  7. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,525
    Vote Rating
    871
    Answers
    3564
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Ok, then this:

    Code:
    Ext.Viewport.add(HelloWorld.Modella1().show);
    should be:

    Code:
    Ext.Viewport.add(new HelloWorld.Modella1());
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  8. #7
    Sencha User
    Join Date
    Dec 2011
    Posts
    10
    Vote Rating
    0
    and cop is on a distinguished road

      0  

    Default


    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

  9. #8
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,525
    Vote Rating
    871
    Answers
    3564
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Is there something in the HelloWorld.Modella1 class that is being created outside the class?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  10. #9
    Sencha User
    Join Date
    Dec 2011
    Posts
    10
    Vote Rating
    0
    and cop is on a distinguished road

      0  

    Default


    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();
    }


    });

  11. #10
    Sencha User
    Join Date
    Dec 2011
    Posts
    10
    Vote Rating
    0
    and cop is on a distinguished road

      0  

    Thumbs up


    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.