-
4 Sep 2008 11:13 PM #1
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
but it work only for firefox and have problem in IE6.PHP Code:Ext.History.myFunc = function(){
//do something
};
Do I missed something ?
Thanks for help.Sorry for my bad English.
-
4 Sep 2008 11:18 PM #2
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!
-
4 Sep 2008 11:30 PM #3
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.
-
5 Sep 2008 3:08 AM #4
My problem exactly is how can I override function handleStateChange in history.js file
It's a private function.PHP Code:function handleStateChange(token) {
currentToken = token;
Ext.History.fireEvent('change', token);
}
Can anybody help me ?
ThanksSorry for my bad English.
-
5 Sep 2008 3:09 AM #5
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!
-
5 Sep 2008 3:10 AM #6Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28
Ext.apply should be what you want.

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
5 Sep 2008 3:52 AM #7
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.
-
5 Sep 2008 3:55 AM #8Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28
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
Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
5 Sep 2008 4:08 AM #9
I meant how do I override a private Function ? Your code work because pubFn1 is a public Function.
handleStateChange is a private function.PHP Code:function handleStateChange(token) {
currentToken = token;
Ext.History.fireEvent('change', token);
}
Sorry for my bad English.
-
5 Sep 2008 4:12 AM #10Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28
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();
Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.


Reply With Quote