Created
July 7, 2011 07:32
-
-
Save bmoeskau/1069043 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Overriding via the string class name will lazy-override the class: | |
| Ext.override('Ext.Panel', { | |
| // override the default value of a config: | |
| frame: true, | |
| // override a method: | |
| setTitle: function(newTitle) { | |
| this.callOverridden(['First: ' + newTitle]); | |
| } | |
| }); | |
| Ext.Loader.setPath('My.overrides', ''); | |
| Ext.require([ | |
| // Overrides can also be named and required, before or | |
| // after the target class is defined, and multiple overrides | |
| // can be defined for the same target class: | |
| 'My.overrides.Panel', | |
| 'Ext.panel.Panel', | |
| 'My.overrides.Panel2' | |
| ], | |
| function() { | |
| Ext.Panel.override({ | |
| // And of course in the require callback you'll finally | |
| // have a class reference, so the traditional syntax will work: | |
| setTitle: function(newTitle) { | |
| this.callOverridden(['Last: ' + newTitle]); | |
| } | |
| }); | |
| }); | |
| Ext.onReady(function() { | |
| var p = Ext.createWidget('panel', { | |
| renderTo: Ext.getBody(), | |
| width: 400, | |
| height: 200, | |
| collapsible: true, | |
| html: 'I am a cool little panel', | |
| bodyStyle: 'padding:10px;', | |
| title: 'A Panel' | |
| }); | |
| p.setTitle('Updated title'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment