1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    2
    Vote Rating
    0
    Cyclope is on a distinguished road

      0  

    Default Answered: Prevent panel from closing when [X] is clicked

    Answered: Prevent panel from closing when [X] is clicked


    Hello.
    I have panel where I render some data from database, it looks like this:
    Code:
    Ext.define('MY.view.CForm', {
        extend: 'Ext.form.Panel',
        
        
        constructor: function(config) {
            return this.callParent(arguments);
        },
    
        initComponent: function(){
    
            Ext.apply(this,{
                id: 'form',
                resizable: true,
                autoScroll: true,
    this is jut the begining, I'm not sure if I have to write the whole code since I want an exact functionality which is - when an user click the [X] icon to stop the action from executing and instead to show maybe a confirmation box asking if the user is certain to close the panel or want to keep it. I went through the documentation and I reach to the conclusion that this can be done using:
    Code:
    listeners: {
                    beforedestroy: function() {
                        //console.log('Test');
                    }
                }
    and here is the part that I simply don't understand. I read that I have to fire an event and retrurn false in order to accomplish what I need but I don't know how to do it in practice. Could anyone help me with any real life example on how to perform such kind of operation or explanation how to construct my event inside the beforedestroy listener, and how exactly to use this event so that I can stop my panel from closing.

    Thanks

  2. PHP Code:
    Ext.create'Ext.window.Window', {
        
    title'test',
        
    width200,
        
    height200,
        
    listeners: {
            
    beforeclose: function( window ) {
                
    Ext.Msg.confirm'Hey''Are you sure you want to close?', function( answer ) {
                    if( 
    answer == "yes" ) {
                        
    window.destroy();
                    }
                } );
                return 
    false;
            }
        }
    } ).
    show(); 

  3. #2
    Sencha User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    536
    Answers
    61
    Vote Rating
    70
    Tim Toady is a jewel in the rough Tim Toady is a jewel in the rough Tim Toady is a jewel in the rough Tim Toady is a jewel in the rough

      0  

    Default


    PHP Code:
    Ext.create'Ext.window.Window', {
        
    title'test',
        
    width200,
        
    height200,
        
    listeners: {
            
    beforeclose: function( window ) {
                
    Ext.Msg.confirm'Hey''Are you sure you want to close?', function( answer ) {
                    if( 
    answer == "yes" ) {
                        
    window.destroy();
                    }
                } );
                return 
    false;
            }
        }
    } ).
    show(); 

  4. #3
    Sencha User
    Join Date
    May 2012
    Posts
    2
    Vote Rating
    0
    Cyclope is on a distinguished road

      0  

    Default


    That was fast, thanks for the response. But will this gonna work for Ext.form.Panel? I saw something similiar and I think that I cant use "window" as a parameter in beforeclose: function( window ) in my case, but maybe I have mistake somewhere..

  5. #4
    Sencha User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    536
    Answers
    61
    Vote Rating
    70
    Tim Toady is a jewel in the rough Tim Toady is a jewel in the rough Tim Toady is a jewel in the rough Tim Toady is a jewel in the rough

      0  

    Default


    Sorry. I didn't read it closely enough to notice it was a panel you were closing. It should work the same, though I have never tried it. As far as the window parameter is concerned, the name is arbitrary. Just change it to something that makes more sense. The component that the event is fired on is passed as the first param.

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi