1. #1
    Sencha User DTT_11-1983's Avatar
    Join Date
    Apr 2008
    Posts
    92
    Vote Rating
    2
    DTT_11-1983 is on a distinguished road

      0  

    Default Help - How to extend Ext.History

    Help - How to extend Ext.History


    I was try many way to do this but all unsuccessfull. I tried Ext.apply, Ext.extend, Ext.override but non of its work.
    I tried
    PHP Code:
    Ext.History.myFunc = function(){
        
    //do something
    }; 
    but it work only for firefox and have problem in IE6.
    Do I missed something ?
    Thanks for help.
    Sorry for my bad English.

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,002
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    History is a singleton, so while it's possible to extend, it's probably easier not to. Can you put the helper methods onto some other static class?
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User DTT_11-1983's Avatar
    Join Date
    Apr 2008
    Posts
    92
    Vote Rating
    2
    DTT_11-1983 is on a distinguished road

      0  

    Default


    All i want to do is write some my own method for Ext.history but i don't want write it direct to ext-all-debug.js. What I have to do now ? I dont know why it work on FireFox but not in IE6.
    Sorry for my bad English.

  4. #4
    Sencha User DTT_11-1983's Avatar
    Join Date
    Apr 2008
    Posts
    92
    Vote Rating
    2
    DTT_11-1983 is on a distinguished road

      0  

    Default


    My problem exactly is how can I override function handleStateChange in history.js file
    PHP Code:
        function handleStateChange(token) {
            
    currentToken token;
            
    Ext.History.fireEvent('change'token);
        } 
    It's a private function.
    Can anybody help me ?
    Thanks
    Sorry for my bad English.

  5. #5
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,002
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    If you really have to, then just copy the source and make the appropriate changes.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  6. #6
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,361
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Ext.apply should be what you want.

  7. #7
    Sencha User DTT_11-1983's Avatar
    Join Date
    Apr 2008
    Posts
    92
    Vote Rating
    2
    DTT_11-1983 is on a distinguished road

      0  

    Default


    I've tried that method already but It still run the defaut function in ext-all-debug.js file. I can't make it run my function that I applied.
    Sorry for my bad English.

  8. #8
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,361
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Paste the following in firebug, it works:
    Code:
    var mySingleton = function() {
        var priv1 = 'some private string';
    
        return {
            pubFn1 : function() {
                console.info('original pubfn1');
            },
            pubFn2 : function() {
                console.info('original pubfn2');
            }
    
    
        }
    
    
    }();
    
    Ext.apply(mySingleton, {
    
        pubFn1 : function() {
            console.info('NEW pubfn1 via override');
        }
    
    });
    
    mySingleton.pubFn1();a

  9. #9
    Sencha User DTT_11-1983's Avatar
    Join Date
    Apr 2008
    Posts
    92
    Vote Rating
    2
    DTT_11-1983 is on a distinguished road

      0  

    Default


    I meant how do I override a private Function ? Your code work because pubFn1 is a public Function.
    PHP Code:
        function handleStateChange(token) {

            
    currentToken token;

            
    Ext.History.fireEvent('change'token);

        } 
    handleStateChange is a private function.
    Sorry for my bad English.

  10. #10
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,361
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Like evant said, you can't unless you override the source from the file or make your own history obj:

    Code:
    var mySingleton = function() {
        var priv1 = 'some private string';
        function test() {
            console.info('this is a test');
        }
        return {
            pubFn1 : function() {
                console.info('original pubfn1');
                test();
            },
            pubFn2 : function() {
                console.info('original pubfn2');
    
            }
    
    
        }
    
    
    }();
    
    Ext.apply(mySingleton, {
    
        pubFn3 : function() {
            test()
        }
    
    });
    
    mySingleton.pubFn3();

Thread Participants: 2