1. #1
    Sencha User
    Join Date
    Dec 2011
    Location
    White Rock, BC Canada
    Posts
    161
    Answers
    11
    Vote Rating
    0
    WagsMax is on a distinguished road

      0  

    Default Answered: How to dispatch in new ST Designer Beta?

    Answered: How to dispatch in new ST Designer Beta?


    In ST1.1 I was able to dispatch an event to the specified controller with:
    Code:
        onPrintAction: function() {
            Ext.dispatch({
                controller: 'FieldCall',
                action: 'printTest',
                form: this
            });
        },

    and in the FieldCall controller catch the dispatch with:
    Code:
        printTest: function(params) {
            try {
                window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
            }
            catch (e) {
                console.log("Caught error in printTest");
            }
        },

    My question is: do you still do things this way when using Designer or is there a better way? If you do it the same way with Designer, how do you do it?

  2. MVC in ST2 is pretty different than in ST1. You don't need to use Ext.dispatch to get a component event to be fired onto the controller. You can use the control config in the config object.

    So in Designer, you create a controller and then you create a controller action. Then you fill out a couple configs on the action and then you can enter code.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,013
    Answers
    3490
    Vote Rating
    846
    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


    MVC in ST2 is pretty different than in ST1. You don't need to use Ext.dispatch to get a component event to be fired onto the controller. You can use the control config in the config object.

    So in Designer, you create a controller and then you create a controller action. Then you fill out a couple configs on the action and then you can enter code.
    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
    Location
    White Rock, BC Canada
    Posts
    161
    Answers
    11
    Vote Rating
    0
    WagsMax is on a distinguished road

      0  

    Default


    Would it be possible to give me a short walk-through on that? I can't find the "config" thing you are talking about in any of my objects.

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,013
    Answers
    3490
    Vote Rating
    846
    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


    In Designer you do all your configurations in the config panel that is at the bottom-right after you click on a class either in the viewport or in the project inspector.
    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
    Location
    White Rock, BC Canada
    Posts
    161
    Answers
    11
    Vote Rating
    0
    WagsMax is on a distinguished road

      0  

    Default


    Ok, I see now what you mean by the config. Another question... in ST1.1 you used to be able to send "extra" params to the event handler like 'form' below in ST1.1. How do we do this now in Designer?

    Code:
        onSomeAction: function() {
            Ext.dispatch({
                controller: 'MyController',
                action: 'Test',
                form: this
            });
        },

  7. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,013
    Answers
    3490
    Vote Rating
    846
    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


    Since you don't use Ext.dispatch anymore we are just listening to events being fired you don't have that access.
    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
    Location
    White Rock, BC Canada
    Posts
    161
    Answers
    11
    Vote Rating
    0
    WagsMax is on a distinguished road

      0  

    Default


    Ok, then how do you (from the controller) get a handle on the view that fired the event, so that you can do something on that view, e.g. something simple, like change the title of a button?

  9. #8
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,013
    Answers
    3490
    Vote Rating
    846
    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


    Check out the arguments that are fired with the event. Usually, the component that is firing the event is the first argument.
    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
    Location
    White Rock, BC Canada
    Posts
    161
    Answers
    11
    Vote Rating
    0
    WagsMax is on a distinguished road

      0  

    Default


    Ok, I see that. Now I have put this code in the event handler for the button... ("button" is the first argument):

    Code:
    button.setTitle('Test');
    and I get this error:
    Uncaught TypeError: Object [object Object] has no method 'setTitle'

  11. #10
    Sencha User
    Join Date
    Dec 2011
    Location
    White Rock, BC Canada
    Posts
    161
    Answers
    11
    Vote Rating
    0
    WagsMax is on a distinguished road

      0  

    Default


    Oops, I messed up, it should have been setText. It works now.

Thread Participants: 1