Results 1 to 6 of 6

Thread: using id's as refs in a controller

  1. #1

    Default using id's as refs in a controller

    Hey,

    I'm wondering how the refs in a controller work?
    When a controllers links a ref to an "#id", and the view which holds this "#id" gets destroyed and re-created, the ref won't work anymore?

    Does the controller only make the link on creation of the controller?
    If so is there a way to load the controller when the view is created, but the controller still needs to be accessible through App.app.getController('...').

  2. #2

    Default

    is there maybe a way to let a controller re-evaluate it's refs?
    or is there something better to use then the #id of an item?

  3. #3
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,388
    Answers
    3997

    Default

    The id config should only be used for debugging and not in production code. The refs use ComponentQuery to resolve the instances so you can use xtypes and properties to resolve instances.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  4. #4

    Default

    Ok, i'll look into that.

    But i noticed the refs seem to work but its the control part thats not working?
    so i got something like the following:
    Code:
    refs: {
         weekList: '#weekList'
    },
    control: {
         "weekList": {
              itemtap: 'onWeekListItemTap',
              painted: 'onWeekListShown'
         }
    }
    but the painted event doesn't get called when my view gets created for the second time?

  5. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    103
    Answers
    5

    Default

    If you really want to use the ID (as Mitchell said before, really not the recommanded way) :
    Code:
    refs: {     
         weekList: '#weekList'
    },
    control: {    
         weekList: {          
             itemtap: 'onWeekListItemTap',          
             painted: 'onWeekListShown'     
         }
    }
    Actually, you have to remove the quotes to use the weekList defined in the refs (#weekList). Using quotes ("weekList") means that you're referencing weekList as its xtype.

  6. #6

    Default

    yup, thx for pointing that out... think i must have changed that while trying all sort of stuff out.

    I've got it to work now. I now listen for the show event on the cointainer around the list. Because the one on the list wouldn't go off since i want to load the data from its store when the list is shown.

    And painted doesn't bubble to the controller i've read in the documents? although using painted on the ref with the "#id" does work in my controller?

    Thx for helping me out with this

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •