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


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // this is an event manager implementation of a logout button
  2. // for usage in Extjs (Sencha). This is just an excerpt, don't see
  3. // this as a complete event manager
  4.  
  5. // usage in on a button in a panel (don't include this in an event manager
  6. // but in your own panels
  7.  
  8. // {
  9. // text : 'Logout',
  10. // handler : function ( b, e ) {
  11. // base.eventManager.fireEvent('iconlogoutclicked' , b, e )
  12. // }
  13.  
  14. Ext.ns('base');
  15.  
  16. base.eventManager = Ext.extend(Ext.util.Observable, {
  17.  
  18. constructor : function ( config ) {
  19.  
  20. // events to register
  21. this.addEvents ({
  22. 'iconlogoutclicked' : true, // simple sample of a logout event
  23. });
  24.  
  25. this.on('iconlogoutclicked', this.onIconLogoutClicked, this);
  26.  
  27. // apply to this object
  28. Ext.apply(this,config)
  29.  
  30. },
  31.  
  32. onIconLogoutClicked : function ( button, event) {
  33. // show dialog with confirmation
  34. Ext.Msg.show({
  35. title :'Logout',
  36. msg : 'Sind Sie sicher das Sie sich abmelden möchten ?',
  37. buttons : Ext.Msg.OKCANCEL,
  38. fn : this.processLogout,
  39. icon : Ext.MessageBox.QUESTION
  40. });
  41. },
  42.  
  43. processLogout : function ( btn) {
  44. if (btn == 'ok' ) self.location = '' // put here your own redirect, this is going to the root page
  45. },
  46.  
  47.  
  48. });
  49.  
  50. base.eventManager = new base.eventManager;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.