1. #1
    Sencha User jep's Avatar
    Join Date
    Sep 2010
    Posts
    862
    Vote Rating
    21
    jep will become famous soon enough jep will become famous soon enough

      0  

    Default itemId versus id, dynamically created views, refs and control

    itemId versus id, dynamically created views, refs and control


    It seems like ST 2's refs really encourages you to use ids (the docs certainly do). It also seems that in general, dynamically creating your views and then destroying them when they're not in use to save resources is also the best thing to do. But it seems like when you try to put those together in ST 2, they don't exactly mesh very well.

    Or maybe I'm just doing things wrong (the docs aren't helping point me in the right direction, if so).

    I have a main view and some sub views. I have a button on the a sub view. I want to hook up some events to the sub view and to that specific button. I have to set up the refs like this:

    Code:
    refs:{
      subView:'[itemId=subView]',
      subViewButton:'[itemId=subViewButton]'
    },
    control:{
      subView:{
        initialize:'subViewInitialize'
      },
      subViewButton:{
        initialize:'subViewButtonInitialize'
      }
    }
    If you don't use the "[itemId=]" syntax, the events never hook up (or worse, if you use id instead of itemId, they only hook up the first time).

    It just seems so... clunky. I just really wish the refs syntax understood how to find a component by itemId without resorting to the attribute syntax. What I thought was an elegant system when I was reading through the docs and trying simple examples turned into something much less so when I went to build a real world application.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,797
    Vote Rating
    834
    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


    I'm assuming you tried?

    Code:
    refs:{
      subView:'#subView',
      subViewButton:'#subViewButton'
    },
    control:{
      subView:{
        initialize:'subViewInitialize'
      },
      subViewButton:{
        initialize:'subViewButton'
      }
    }
    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.

  3. #3
    Sencha User jep's Avatar
    Join Date
    Sep 2010
    Posts
    862
    Vote Rating
    21
    jep will become famous soon enough jep will become famous soon enough

      0  

    Default


    When I did that, the initialize functions were never called. Does it work differently for you?

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,797
    Vote Rating
    834
    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


    No, was just seeing if you do '#someitemid' then it wouldn't work as it would look for an id of that (which won't work if you destroy a component and recreate it.
    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.

  5. #5
    Sencha User jep's Avatar
    Join Date
    Sep 2010
    Posts
    862
    Vote Rating
    21
    jep will become famous soon enough jep will become famous soon enough

      0  

    Default


    That was one of the points I made in the original message.

    So, am I pretty much right on the limitations/structure of the api? Is this clunky way of doing it pretty much how you have to do it if you want to write good applications that create/destroy views on demand?

  6. #6
    Sencha User jep's Avatar
    Join Date
    Sep 2010
    Posts
    862
    Vote Rating
    21
    jep will become famous soon enough jep will become famous soon enough

      0  

    Default


    Argh. I just noticed I accidentally posted this in Bugs. It was supposed to go in Discussion.

    Can you move it, Mitchell? Thanks.

    Edit: Thanks for moving it.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi