class type t =Inheritsobject
..end
method application : 'a. 'a Js.t Js.readonly_prop
The Ext.app.Application for this controller.
method addRef : 'b. 'b Js.t -> unit Js.meth
method control : 'c 'd. 'c Js.t -> 'd Js.t Js.optdef -> unit Js.meth
Adds listeners to components selected via Ext.ComponentQuery. Accepts an object containing component paths mapped to a hash of listener functions.
In the following example the updateUser
function is mapped to to the click
event on a button component, which is a child of the useredit
component.
Ext.define('AM.controller.Users', {
init: function() {
this.control({
'useredit button[action=save]': {
click: this.updateUser
}
});
},
updateUser: function(button) {
console.log('clicked the Save button');
}
});
Or alternatively one call control
with two arguments:
this.control('useredit button[action=save]', {
click: this.updateUser
});
See Ext.ComponentQuery for more information on component selectors.
Parameters:
_ Js.t
If a String, the second argument is used as the listeners, otherwise an object of selectors -> listeners is assumed
_ Js.t
(optional) Config for listeners.
method getApplication : 'e. 'e Js.t Js.meth
Returns the base Ext.app.Application for this controller.
Returns:
Ext_app_Application.t Js.t
the application
method getController : Js.js_string Js.t ->
(< addEvents : 'h. 'h Js.t -> unit Js.meth;
addListener : 'i 'j 'k 'l 'm.
'i Js.t ->
'j Js.callback Js.optdef ->
'k Js.t Js.optdef -> 'l Js.t Js.optdef -> 'm Js.t Js.meth;
addManagedListener : 'n 'o 'p 'q 'r 's.
'n Js.t ->
'o Js.t ->
'p Js.callback Js.optdef ->
'q Js.t Js.optdef ->
'r Js.t Js.optdef -> 's Js.t Js.meth;
addRef : 'b. 'b Js.t -> unit Js.meth;
application : 'a. 'a Js.t Js.readonly_prop;
callParent : 't 'u. 't Js.t -> 'u Js.t Js.meth;
callSuper : 'v 'w. 'v Js.t -> 'w Js.t Js.meth;
clearListeners : unit Js.meth; clearManagedListeners : unit Js.meth;
control : 'c 'd. 'c Js.t -> 'd Js.t Js.optdef -> unit Js.meth;
enableBubble : 'x. 'x Js.t -> unit Js.meth;
fireEvent : 'y. Js.js_string Js.t -> 'y Js.t -> bool Js.t Js.meth;
fireEventArgs : 'z.
Js.js_string Js.t ->
'z Js.t Js.js_array Js.t -> bool Js.t Js.meth;
getApplication : 'e. 'e Js.t Js.meth; getController : 'f;
getInitialConfig : 'a1. Js.js_string Js.t Js.optdef -> 'a1 Js.t Js.meth;
getModel : Js.js_string Js.t -> Ext_data_Model.t Js.t Js.meth;
getStore : Js.js_string Js.t -> Ext_data_Store.t Js.t Js.meth;
getView : 'b1. Js.js_string Js.t -> (#Ext_Base.t as 'b1) Js.t Js.meth;
hasListener : Js.js_string Js.t -> bool Js.t Js.meth;
hasListeners : 'c1. 'c1 Js.t Js.readonly_prop;
hasRef : 'd1. 'd1 Js.t -> bool Js.t Js.meth;
init : 'e1. 'e1 Js.t -> unit Js.meth;
initConfig : 'f1. 'f1 Js.t -> 'g Js.t Js.meth;
isObservable : bool Js.t Js.prop; listen : 'g1. 'g1 Js.t -> unit Js.meth;
mon : 'h1 'i1 'j1 'k1 'l1 'm1.
'h1 Js.t ->
'i1 Js.t ->
'j1 Js.callback Js.optdef ->
'k1 Js.t Js.optdef -> 'l1 Js.t Js.optdef -> 'm1 Js.t Js.meth;
mun : 'n1 'o1 'p1 'q1.
'n1 Js.t ->
'o1 Js.t ->
'p1 Js.callback Js.optdef -> 'q1 Js.t Js.optdef -> unit Js.meth;
on : 'r1 's1 't1 'u1 'v1.
'r1 Js.t ->
's1 Js.callback Js.optdef ->
't1 Js.t Js.optdef -> 'u1 Js.t Js.optdef -> 'v1 Js.t Js.meth;
onLaunch : 'w1. 'w1 Js.t -> unit Js.meth;
relayEvents : 'x1 'y1.
'x1 Js.t ->
Js.js_string Js.t Js.js_array Js.t ->
Js.js_string Js.t Js.optdef -> 'y1 Js.t Js.meth;
removeListener : 'z1 'a2.
Js.js_string Js.t ->
'z1 Js.callback -> 'a2 Js.t Js.optdef -> unit Js.meth;
removeManagedListener : 'b2 'c2 'd2 'e2.
'b2 Js.t ->
'c2 Js.t ->
'd2 Js.callback Js.optdef ->
'e2 Js.t Js.optdef -> unit Js.meth;
resumeEvent : Js.js_string Js.t -> unit Js.meth;
resumeEvents : unit Js.meth; self : Ext_Class.t Js.t Js.prop;
statics : Ext_Class.t Js.t Js.meth;
suspendEvent : Js.js_string Js.t -> unit Js.meth;
suspendEvents : bool Js.t -> unit Js.meth;
un : 'f2 'g2.
Js.js_string Js.t ->
'f2 Js.callback -> 'g2 Js.t Js.optdef -> unit Js.meth;
.. >
as 'g)
Js.t Js.meth as 'f
Returns instance of a Controller with the given id. When controller doesn't exist yet, it's created. Note that this method depends on Application instance and will return undefined when Application is not accessible. The only exception is when this Controller instance's id is requested; in that case we always return the instance even if Application is no available.
Parameters:
Js.js_string Js.t
Returns:
Ext_app_Controller.t Js.t
controller instance or undefined.
method getModel : Js.js_string Js.t -> Ext_data_Model.t Js.t Js.meth
Returns a Model class with the given name. A shorthand for using Ext.ModelManager.getModel.
Parameters:
Js.js_string Js.t
Returns:
Ext_data_Model.t Js.t
a model class.
method getStore : Js.js_string Js.t -> Ext_data_Store.t Js.t Js.meth
Returns instance of a Store with the given name. When store doesn't exist yet, it's created.
Parameters:
Js.js_string Js.t
Returns:
Ext_data_Store.t Js.t
a store instance.
method getView : 'b1. Js.js_string Js.t -> (#Ext_Base.t as 'b1) Js.t Js.meth
Returns a View class with the given name. To create an instance of the view, you can use it like it's used by Application to create the Viewport:
this.getView('Viewport').create();
Parameters:
Js.js_string Js.t
Returns:
#Ext_Base.t Js.t
a view class.
method hasRef : 'd1. 'd1 Js.t -> bool Js.t Js.meth
method init : 'e1. 'e1 Js.t -> unit Js.meth
A template method that is called when your application boots. It is called before the Application's launch function is executed so gives a hook point to run any code before your Viewport is created.
Parameters:
Ext_app_Application.t Js.t
method listen : 'g1. 'g1 Js.t -> unit Js.meth
Adds listeners to different event sources (also called "event domains"). The primary event domain is that of components, but there are also other event domains: Global domain that intercepts events fired from Ext.globalEvents Observable instance, Controller domain can be used to listen to events fired by other Controllers, Store domain gives access to Store events, and Direct domain can be used with Ext.Direct Providers to listen to their events.
To listen to "bar" events fired by a controller with id="foo":
Ext.define('AM.controller.Users', {
init: function() {
this.listen({
controller: {
'#foo': {
bar: this.onFooBar
}
}
});
},
...
});
To listen to "bar" events fired by any controller, and "baz" events fired by Store with storeId="baz":
Ext.define('AM.controller.Users', {
init: function() {
this.listen({
controller: {
'*': {
bar: this.onAnyControllerBar
}
},
store: {
'#baz': {
baz: this.onStoreBaz
}
}
});
},
...
});
To listen to "idle" events fired by Ext.globalEvents when other event processing is complete and Ext JS is about to return control to the browser:
Ext.define('AM.controller.Users', {
init: function() {
this.listen({
global: { // Global events are always fired
idle: this.onIdle // from the same object, so there
} // are no selectors
});
}
});
As this relates to components, the following example:
Ext.define('AM.controller.Users', {
init: function() {
this.listen({
component: {
'useredit button[action=save]': {
click: this.updateUser
}
}
});
},
...
});
Is equivalent to:
Ext.define('AM.controller.Users', {
init: function() {
this.control({
'useredit button[action=save]': {
click: this.updateUser
}
});
},
...
});
Of course, these can all be combined in a single call and used instead of
control
, like so:
Ext.define('AM.controller.Users', {
init: function() {
this.listen({
global: {
idle: this.onIdle
},
controller: {
'*': {
foobar: this.onAnyFooBar
},
'#foo': {
bar: this.onFooBar
}
},
component: {
'useredit button[action=save]': {
click: this.updateUser
}
},
store: {
'#qux': {
load: this.onQuxLoad
}
}
});
},
...
});
Parameters:
_ Js.t
Config object containing domains, selectors and listeners.
method onLaunch : 'w1. 'w1 Js.t -> unit Js.meth