Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: How can I use refs in control actions?

  1. #11
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    52
    Vote Rating
    12
      0  

    Default

    No problem, what are you trying to do? My mentioned of not needing quotes was in reference to the instructions I had given:

    -Put an id of "myButton" on the button (no quotes)

    Sencha does put the quotes on there, but it works and only the ref will now trigger the action. Did you follow the instructions or download that sample I uploaded? Are you just trying to get a reference to a component or something more complicated than that?

  2. #12
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    88
    Vote Rating
    5
      0  

    Default

    I think I might have misunderstood something here.

    Looking at your button.xda example. Is there anyway you could have used the myButton ref in the control object.

    So rather then,
    Code:
    Ext.define('MyApp.controller.MyController', {    extend: 'Ext.app.Controller',
        config: {
            refs: {
                myButton: '#myButton'
            },
    
    
            control: {
                "button": {
                    tap: 'onButtonTap'
                }
            }
        },//other code omitted
    Something like
    Code:
    Ext.define('MyApp.controller.MyController', {    extend: 'Ext.app.Controller',
        config: {
            refs: {
                myButton: '#myButton'
            },
    
    
            control: {
                "myButton": { // use a ref here
                    tap: 'onButtonTap'
                }
            }
        },

  3. #13
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    52
    Vote Rating
    12
      0  

    Default

    Yes, you can do exactly that - just select the "tap" action for the button and then in the Config panel set the ControlQuery to the id of the button (see attached screenshot). Also attached is a working example that shows myButton which will pop up a dialog when tapped, there's also a second button to show that it does not trigger the same action when tapped

    Does that answer your question?
    Attached Images Attached Images
    Attached Files Attached Files

  4. #14
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    88
    Vote Rating
    5
      1  

    Default

    So I realize you can use a component query in the control section, what I meant was there a way to work through the ref exclusively.

    So if you ref was
    Code:
    refs : { fooRef : "#mybutton" }
    Could you do something like
    Code:
    control { fooRef : { tap: somefunction }}
    I haven't been able to get it to work, but if it doesn't work I don't have a problem using component queries. I would have just been nice to have refs do everything just for the purpose of DRY design.

  5. #15
    Sencha Premium Member
    Join Date
    Dec 2011
    Posts
    20
    Vote Rating
    3
      1  

    Default

    I'd love to know the answer to this as well. The framework allows unquoted property names to mean the ref name but it seems there is no provision in Architect to generate the config that way.

    Perhaps the Controller Action section could have a property with a dropdown picker that lists all the defined refs?

  6. #16
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,487
    Vote Rating
    145
      0  

    Default

    Quote Originally Posted by MDSIII View Post
    I'd love to know the answer to this as well. The framework allows unquoted property names to mean the ref name but it seems there is no provision in Architect to generate the config that way.
    There is no difference between quoted and unquoted references. You can still use this feature of the framework.
    Aaron Conran
    @aconran

  7. #17
    Sencha Premium Member
    Join Date
    Dec 2011
    Posts
    20
    Vote Rating
    3
      0  

    Default

    Quote Originally Posted by aconran View Post
    There is no difference between quoted and unquoted references. You can still use this feature of the framework.
    Thank you. A little more searching the forums and a little more care with my ref selector next time.
    My selector wouldn't find the component by itemId alone. It is a child of a container so I had to put the xtype of the container first. Is this right? e.g.

    Code:
        config: {
            refs: {
                taskNavPanel: {
                    autoCreate: true,
                    selector: 'taskpanel',
                    xtype: 'taskpanel'
                },
                taskList: 'taskpanel #taskList'
            },

  8. #18
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,487
    Vote Rating
    145
      0  

    Default

    Yes, you can either prequalify it via a parent item and/or you could put its xtype#myItemId.
    Aaron Conran
    @aconran

Page 2 of 2 FirstFirst 12

Posting Permissions

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