1. #1
    Sencha User
    Join Date
    May 2011
    Posts
    3
    Vote Rating
    0
    Anth0 is on a distinguished road

      0  

    Default How does fireEvent work on an Observable ?

    How does fireEvent work on an Observable ?


    Hi all,

    I'm trying to fire an event from my view to be caught within my controller but I can't make it work so far and I don't understand why.

    Here is the view :
    Code:
    Ext.define('GP.view.Main', {
        extend: 'Ext.tab.Panel',
        alias: 'widget.mainPanel',
    
    
        config: {
            layout: {
                animation: 'flip',
                type: 'card'
            },
            items: [
                {
                    xtype: 'container',
                    title: 'Pleins',
                    iconCls: 'bookmarks',
                    items: [
                        {
                            xtype: 'toolbar',
                            docked: 'top',
                            title: 'Liste des pleins',
                            items: [
                                {
                                    xtype: 'spacer'
                                },
                                {
                                    xtype: 'button',
                                    id: 'ajouterPlein',
                                    itemId: '',
                                    ui: 'action',
                                    iconCls: 'add',
                                    iconMask: true,
                                    text: ''
                                }
                            ]
                        },
                        {
                            xtype: 'list',
                            docked: 'top',
                            height: 380,
                            itemId: 'listePleins',
                            layout: {
                                type: 'fit'
                            },
                            emptyText: '</pre> <div class="liste-pleins-vide">Aucun plein d\'enregistré </div><pre>',
                            itemTpl: [
                                '</pre><div class="liste-pleins-titre"\'>{montant} €   - {date:date(\'d/m/Y\')}</div><div class="liste-pleins-soustitre">{pompe}</div><div class="deleteplaceholder"></div><pre>'
                            ],
                            loadingText: 'Chargement des pleins',
                            store: 'Pleins',
                            onItemDisclosure: true,
                            pinHeaders: false
                        }
                    ]
                },
                {
                    xtype: 'container',
                    title: 'Carte',
                    iconCls: 'maps',
                    items: [
                        {
                            xtype: 'panel',
                            height: 640,
                            layout: {
                                type: 'fit'
                            },
                            items: [
                                {
                                    xtype: 'toolbar',
                                    docked: 'top',
                                    title: 'Carte des pleins'
                                },
                                {
                                    xtype: 'map',
                                    height: 640,
                                    ui: 'light',
                                    useCurrentLocation: true
                                }
                            ]
                        }
                    ]
                }
            ],
            tabBar: {
                docked: 'bottom'
            },
            listeners: [
                {
                    fn: 'onMylistItemTap',
                    event: 'itemtap',
                    delegate: '#listePleins'
                }
            ]
        },
    
    
        onMylistItemTap: function(dataview, index, target, record, e, options) {
            console.log('Tap sur un plein !');
            this.fireEvent('lancerEditeurPlein', record);
        },
    });
    And the associated controller :

    Code:
    Ext.define('GP.controller.Mains', {
        extend: 'Ext.app.Controller',
        config: {
            views: [
                'Main'
            ],
    
    
            refs: {
                pleinForm: {
                    selector: '#pleinForm',
                    xtype: 'pleinForm',
                    autoCreate: true
                }
            }
        },
    
    
        lancerEditeurPlein: function(record, isEdit) {
            console.log('Lancement de l\'éditeur de pleins');
            var pleinForm = this.getPleinForm();
            pleinForm.setRecord(record);
    
    
            if(isEdit == true) {
                pleinForm.add({
                    xtype: 'button',
                    id: 'supprimerPlein',
                    ui: 'decline',
                    text: 'Supprimer'
                });
            }
    
    
            Ext.Viewport.setActiveItem(pleinForm);
        }
    });
    Taping on an item in the view correctly triggers "onMylistItemTap" but does not arrive inside "lancerEditeurPlein".

    What am I missing ?

    Thank you

  2. #2
    Ext JS Premium Member
    Join Date
    Apr 2010
    Location
    Omaha, NE
    Posts
    557
    Vote Rating
    25
    estesbubba will become famous soon enough estesbubba will become famous soon enough

      1  

    Default


    Add this to your controller config{}

    Code:
    control: {
    	lancerEditeurPlein: 'lancerEditeurPlein'
    }

Thread Participants: 1

Tags for this Thread