Book Image

Mastering ExtJS - Second Edition

By : Loiane Avancini
Book Image

Mastering ExtJS - Second Edition

By: Loiane Avancini

Overview of this book

Table of Contents (19 chapters)
Mastering Ext JS Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Logout capability


As the user has the option to log in to the application, the user can also log out from it. Inside the Header class, we have already declared the logout button. The only thing pending is to implement the listener inside MainController.

As the MainController class was created by Sencha Cmd, we are reusing it. The file already has some code in it. Let's remove any listener created by Sencha. MainController will look like this:

Ext.define('Packt.view.main.MainController', {
    extend: 'Ext.app.ViewController',

    requires: [
        'Ext.MessageBox'
    ],

    alias: 'controller.main',

    //we will insert code here
});

In the Header class, we declared the logout button, its reference, and its listener. So we need to implement the onLogout function, as follows:

onLogout: function(button, e, options){

    var me = this;      //#1
    Ext.Ajax.request({
        url: 'php/security/logout.php', //#2
        scope: me,                      //#3
        success: 'onLogoutSuccess...