PDA

View Full Version : 'singleton' view



gkatz
10 Apr 2013, 2:09 AM
Hi all;
in 1.x I had a single overlay used by my app to display stuff on lists clicks (I just changed its content on every click). in 1.x, the overlay was a global parameter. in 2.x with the new MVC structure, I created an overlay view. thing is, I only want one instance of this view and I want it to be shared by multiple views (again, showing/hiding it and updating its content when needed).
what is the proper architectural approach for a thing like this?
thanks.

mitchellsimoens
12 Apr 2013, 4:44 AM
Do somethign like this:


Ext.define('MyApp.view.Overlay', {
extend : 'Ext.Panel',
xtype : 'myapp-overlay',
singleton : true,

config : {
centered : true,
modal : true,
html : 'Foo'
}
});

Ext.application({
name : 'MyApp',

launch : function () {

//needs to be added to viewport
Ext.Viewport.add(MyApp.view.Overlay);
//hide it or else it will show
MyApp.view.Overlay.hide();

}
});