Skip to content

Instantly share code, notes, and snippets.

@bmoeskau
Created July 7, 2011 07:32
Show Gist options
  • Select an option

  • Save bmoeskau/1069043 to your computer and use it in GitHub Desktop.

Select an option

Save bmoeskau/1069043 to your computer and use it in GitHub Desktop.
// 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