Extjs 4.1.1 Basic mvc

Basic mvc

by molecule

HTML

<link rel="stylesheet" href="http://cdn.sencha.io/ext-4.1.1-gpl/resources/css/ext-all.css">
<script src="http://cdn.sencha.io/ext-4.1.1-gpl/ext-all.js"></script>

JavaScript

Ext.define('AM.controller.Dummy', {
    extend: 'Ext.app.Controller',

    init: function() {
        //console.log('Initialized Dummy! This happens before the Application launch function is called');
        this.control({
            'viewport > panel': {
                render: this.onPanelRendered
            }
        }); 
    },
    
    onPanelClicked: function() {
        alert('The panel was clicked');
    },
    onPanelRendered: function(container) {
        container.on('click',this.onPanelClicked,container,{element: 'el'})
    }
});

Ext.application({
    name: 'AM',

    launch: function() {
        Ext.create('Ext.container.Viewport', {
            layout: 'fit',
            items: [
                {
                    xtype: 'panel',
                    title: 'Users',
                    html : 'Click the panel'
                }
            ]
        });
    },
    
    controllers: [
        'Dummy'
    ],
});