Return to Snippet

Revision: 32437
at September 24, 2010 21:14 by jvandemerwe


Initial Code
// this is an event manager implementation of a logout button
// for usage in Extjs (Sencha). This is just an excerpt, don't see
// this as a complete event manager

// usage in on a button in a panel (don't include this in an event manager
// but in your own panels

// {
//    text       : 'Logout',
//    handler    : function ( b, e ) {
//        base.eventManager.fireEvent('iconlogoutclicked' , b, e )
// }

Ext.ns('base');

base.eventManager = Ext.extend(Ext.util.Observable, {

    constructor    : function ( config ) {

        // events to register
        this.addEvents ({
            'iconlogoutclicked'      : true,   // simple sample of a logout event
        });

        this.on('iconlogoutclicked', this.onIconLogoutClicked, this);

        // apply to this object
        Ext.apply(this,config)

    },

    onIconLogoutClicked : function ( button, event) {
        // show dialog with confirmation
        Ext.Msg.show({
            title     :'Logout',
            msg       : 'Sind Sie sicher das Sie sich abmelden möchten ?',
            buttons   : Ext.Msg.OKCANCEL,
            fn        : this.processLogout,
            icon      : Ext.MessageBox.QUESTION
        });
    },

    processLogout : function ( btn) {
        if (btn == 'ok' ) self.location = ''  // put here your own redirect, this is going to the root page
    },


});

base.eventManager = new base.eventManager;

Initial URL


Initial Description


Initial Title
Extjs: a very useful, but straight forward logout with  jump to another page

Initial Tags


Initial Language
JavaScript