JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://dev.sencha.com/extjs/5.0.0/ext-all-debug.js"></script>
<link rel="stylesheet" href="http://dev.sencha.com/extjs/5.0.0/packages/ext-theme-crisp/build/resources/ext-theme-crisp-all-debug.css">
JavaScript
Ext.onReady(function() {
Ext.define('Ext.state.FakeProvider', {
extend: 'Ext.state.CookieProvider',
set: function(name, value){
console.log('Setting ' + name + ': ' + Ext.encode(value));
this.callParent(arguments);
},
// private
clear : function(name){
console.log('Clearing ' + name);
this.callParent(arguments);
}
});
Ext.state.Manager.setProvider(Ext.create('Ext.state.FakeProvider', {}));
Ext.define('Ext.panel.MyPanel', {
extend: 'Ext.panel.Panel',
config: {
highlight: false
},
updateHighlight: function(value){
if (this.rendered) {
this.body.setStyle('background-color', value ? 'red' : 'white');
}
// fire event to invoke state saveing
this.fireEvent('highlightchange', this, value);
},
initComponent: function() {
// add state events
this.addStateEvents(['myevent','highlightchange']);
this.callParent();
},
getState: function() {
var state = Ext.apply({
// add custom state here
highlight: this.getHighlight()
}, this.callParent());
return state;
},
applyState: function(state) {
console.log('Applying state ' + Ext.encode(state));
// apply custom state here
this.setHighlight(state ? state.highlight : false);
this.callParent(state);
},
onRender: function() {
this.callParent(arguments);
// set color on render
this.body.setStyle('background-color', this.getHighlight() ? 'red' : 'white');
}
});
Ext.create('Ext.panel.MyPanel', {
stateId: 'panel1',
stateful: true,
renderTo:...