I'd like to use a single function onLaunchWindow()
to launch different unique windows. The event is fired in the view and handled by a switch statement in the controller. In this example I'm firing an "add" event. I'd like to expand on this and include other scenarios such as "remove, edit, etc." My problem is I don't want to have to declare the Ext.window
and it's config in my controller but I'm not sure how to proceed otherwise. Ideally I'd like to declare the Ext.window
as an object in my view and pass it to the onLaunchWindow()
function and change it's config on the fly to suite different needs in my application.
More plainly, I think, I need to access and modify the objects config after it has already been constructed.
View
...
,
xtype: "button"
itemId: "testButton"
iconCls: "test-icon test-add"
tooltip: "Launch a Modal with Unique Properties"
hidden: false
margin: "0, 5, 0, 5"
cls:'x-btn-default-small'
border: 1
handler: () =>
action = "add"
@fireEvent( 'launchwindow', action )
style:
borderColor: '#D1D1D1',
borderStyle: 'solid'
,
...
Controller
...
control:
view:
'launchwindow': ( action ) ->
@onLaunchWindow( action )
...
onLaunchWindow: ( action ) ->
switch ( action )
when "add"
window = Ext.create( "Ext.Window",
layout: "fit"
width: 500
height: 300
modal: true
closeAction: "hide"
title: "Add"
items: [ {
} ]
)
...
I've also tried declaring the window as an object in the view and passing it to the onLaunchWindow()
function and setting it's config via Ext.apply()
this works well for one window but I can't seem to reset the config each time the function is called.
Any help would be greatly appreciated!