X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/3789b528d8dd8aad4558e38e22d775bcab1cbd36..HEAD:/docs/output/Ext.app.Controller.js diff --git a/docs/output/Ext.app.Controller.js b/docs/output/Ext.app.Controller.js index 60806b85..8cd57314 100644 --- a/docs/output/Ext.app.Controller.js +++ b/docs/output/Ext.app.Controller.js @@ -1,82 +1 @@ -Ext.data.JsonP.Ext_app_Controller({ - "tagname": "class", - "name": "Ext.app.Controller", - "doc": "
Controllers are the glue that binds an application together. All they really do is listen for events (usually from\nviews) and take some action. Here's how we might create a Controller to manage Users:
\n\nExt.define('MyApp.controller.Users', {\n extend: 'Ext.app.Controller',\n\n init: function() {\n console.log('Initialized Users! This happens before the Application launch function is called');\n }\n});\n
\n\nThe init function is a special method that is called when your application boots. It is called before the\nApplication's launch function is executed so gives a hook point to run any code before\nyour Viewport is created.
\n\nThe init function is a great place to set up how your controller interacts with the view, and is usually used in\nconjunction with another Controller function - control. The control function\nmakes it easy to listen to events on your view classes and take some action with a handler function. Let's update\nour Users controller to tell us when the panel is rendered:
\n\nExt.define('MyApp.controller.Users', {\n extend: 'Ext.app.Controller',\n\n init: function() {\n this.control({\n 'viewport > panel': {\n render: this.onPanelRendered\n }\n });\n },\n\n onPanelRendered: function() {\n console.log('The panel was rendered');\n }\n});\n
\n\nWe've updated the init function to use this.control to set up listeners on views in our application. The control\nfunction uses the new ComponentQuery engine to quickly and easily get references to components on the page. If you\nare not familiar with ComponentQuery yet, be sure to check out THIS GUIDE for a full explanation. In brief though,\nit allows us to pass a CSS-like selector that will find every matching component on the page.
\n\nIn our init function above we supplied 'viewport > panel', which translates to \"find me every Panel that is a direct\nchild of a Viewport\". We then supplied an object that maps event names (just 'render' in this case) to handler\nfunctions. The overall effect is that whenever any component that matches our selector fires a 'render' event, our\nonPanelRendered function is called.
\n\nUsing refs
\n\nOne of the most useful parts of Controllers is the new ref system. These use the new Ext.ComponentQuery to\nmake it really easy to get references to Views on your page. Let's look at an example of this now:
\n\nExt.define('MyApp.controller.Users', {\n extend: 'Ext.app.Controller',\n\n refs: [\n {\n ref: 'list',\n selector: 'grid'\n }\n ],\n\n init: function() {\n this.control({\n 'button': {\n click: this.refreshGrid\n }\n });\n },\n\n refreshGrid: function() {\n this.getList().store.load();\n }\n});\n
\n\nThis example assumes the existence of a Grid on the page, which contains a single button to\nrefresh the Grid when clicked. In our refs array, we set up a reference to the grid. There are two parts to this -\nthe 'selector', which is a ComponentQuery selector which finds any grid on the page and\nassigns it to the reference 'list'.
\n\nBy giving the reference a name, we get a number of things for free. The first is the getList function that we use in\nthe refreshGrid method above. This is generated automatically by the Controller based on the name of our ref, which\nwas capitalized and prepended with get to go from 'list' to 'getList'.
\n\nThe way this works is that the first time getList is called by your code, the ComponentQuery selector is run and the\nfirst component that matches the selector ('grid' in this case) will be returned. All future calls to getList will\nuse a cached reference to that grid. Usually it is advised to use a specific ComponentQuery selector that will only\nmatch a single View in your application (in the case above our selector will match any grid on the page).
\n\nBringing it all together, our init function is called when the application boots, at which time we call this.control\nto listen to any click on a button and call our refreshGrid function (again, this will\nmatch any button on the page so we advise a more specific selector than just 'button', but have left it this way for\nsimplicity). When the button is clicked we use out getList function to refresh the grid.
\n\nYou can create any number of refs and control any number of components this way, simply adding more functions to\nyour Controller as you go. For an example of real-world usage of Controllers see the Feed Viewer example in the\nexamples/app/feed-viewer folder in the SDK download.
\n\nGenerated getter methods
\n\nRefs aren't the only thing that generate convenient getter methods. Controllers often have to deal with Models and\nStores so the framework offers a couple of easy ways to get access to those too. Let's look at another example:
\n\nExt.define('MyApp.controller.Users', {\n extend: 'Ext.app.Controller',\n\n models: ['User'],\n stores: ['AllUsers', 'AdminUsers'],\n\n init: function() {\n var User = this.getUserModel(),\n allUsers = this.getAllUsersStore();\n\n var ed = new User({name: 'Ed'});\n allUsers.add(ed);\n }\n});\n
\n\nBy specifying Models and Stores that the Controller cares about, it again dynamically loads them from the appropriate\nlocations (app/model/User.js, app/store/AllUsers.js and app/store/AdminUsers.js in this case) and creates getter\nfunctions for them all. The example above will create a new User model instance and add it to the AllUsers Store.\nOf course, you could do anything in this function but in this case we just did something simple to demonstrate the\nfunctionality.
\n\nFurther Reading
\n\nFor more information about writing Ext JS 4 applications, please see the \napplication architecture guide. Also see the Ext.app.Application documentation.
\n", - "extends": null, - "mixins": [ - - ], - "alternateClassNames": [ - - ], - "xtype": null, - "author": null, - "docauthor": "Ed Spencer", - "singleton": false, - "private": false, - "cfg": [ - { - "tagname": "cfg", - "name": "id", - "member": "Ext.app.Controller", - "type": "String", - "doc": "The id of this controller. You can use this id when dispatching.
\n", - "private": false, - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/app/Controller.js", - "linenr": 136, - "html_filename": "Controller.html", - "href": "Controller.html#Ext-app-Controller-cfg-id" - } - ], - "method": [ - { - "tagname": "method", - "name": "Controller", - "member": "Ext.app.Controller", - "doc": "\n", - "params": [ - - ], - "return": { - "type": "void", - "doc": "\n" - }, - "private": false, - "static": false, - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/app/Controller.js", - "linenr": 1, - "html_filename": "Controller.html", - "href": "Controller.html#Ext-app-Controller-method-constructor", - "shortDoc": "\n" - } - ], - "property": [ - - ], - "event": [ - - ], - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/app/Controller.js", - "linenr": 1, - "html_filename": "Controller.html", - "href": "Controller.html#Ext-app-Controller", - "cssVar": [ - - ], - "cssMixin": [ - - ], - "component": false, - "superclasses": [ - - ], - "subclasses": [ - "Ext.app.Application" - ], - "mixedInto": [ - - ], - "allMixins": [ - - ] -}); \ No newline at end of file +Ext.data.JsonP.Ext_app_Controller({"tagname":"class","html":"Hierarchy
Ext.BaseExt.app.ControllerMixins
Files
Controllers are the glue that binds an application together. All they really do is listen for events (usually from\nviews) and take some action. Here's how we might create a Controller to manage Users:
\n\nExt.define('MyApp.controller.Users', {\n extend: 'Ext.app.Controller',\n\n init: function() {\n console.log('Initialized Users! This happens before the Application launch function is called');\n }\n});\n
\n\nThe init function is a special method that is called when your application boots. It is called before the\nApplication's launch function is executed so gives a hook point to run any code before\nyour Viewport is created.
\n\nThe init function is a great place to set up how your controller interacts with the view, and is usually used in\nconjunction with another Controller function - control. The control function\nmakes it easy to listen to events on your view classes and take some action with a handler function. Let's update\nour Users controller to tell us when the panel is rendered:
\n\nExt.define('MyApp.controller.Users', {\n extend: 'Ext.app.Controller',\n\n init: function() {\n this.control({\n 'viewport > panel': {\n render: this.onPanelRendered\n }\n });\n },\n\n onPanelRendered: function() {\n console.log('The panel was rendered');\n }\n});\n
\n\nWe've updated the init function to use this.control to set up listeners on views in our application. The control\nfunction uses the new ComponentQuery engine to quickly and easily get references to components on the page. If you\nare not familiar with ComponentQuery yet, be sure to check out the documentation. In brief though,\nit allows us to pass a CSS-like selector that will find every matching component on the page.
\n\nIn our init function above we supplied 'viewport > panel', which translates to \"find me every Panel that is a direct\nchild of a Viewport\". We then supplied an object that maps event names (just 'render' in this case) to handler\nfunctions. The overall effect is that whenever any component that matches our selector fires a 'render' event, our\nonPanelRendered function is called.
\n\nUsing refs
\n\nOne of the most useful parts of Controllers is the new ref system. These use the new Ext.ComponentQuery to\nmake it really easy to get references to Views on your page. Let's look at an example of this now:
\n\nExt.define('MyApp.controller.Users', {\n extend: 'Ext.app.Controller',\n\n refs: [\n {\n ref: 'list',\n selector: 'grid'\n }\n ],\n\n init: function() {\n this.control({\n 'button': {\n click: this.refreshGrid\n }\n });\n },\n\n refreshGrid: function() {\n this.getList().store.load();\n }\n});\n
\n\nThis example assumes the existence of a Grid on the page, which contains a single button to\nrefresh the Grid when clicked. In our refs array, we set up a reference to the grid. There are two parts to this -\nthe 'selector', which is a ComponentQuery selector which finds any grid on the page and\nassigns it to the reference 'list'.
\n\nBy giving the reference a name, we get a number of things for free. The first is the getList function that we use in\nthe refreshGrid method above. This is generated automatically by the Controller based on the name of our ref, which\nwas capitalized and prepended with get to go from 'list' to 'getList'.
\n\nThe way this works is that the first time getList is called by your code, the ComponentQuery selector is run and the\nfirst component that matches the selector ('grid' in this case) will be returned. All future calls to getList will\nuse a cached reference to that grid. Usually it is advised to use a specific ComponentQuery selector that will only\nmatch a single View in your application (in the case above our selector will match any grid on the page).
\n\nBringing it all together, our init function is called when the application boots, at which time we call this.control\nto listen to any click on a button and call our refreshGrid function (again, this will\nmatch any button on the page so we advise a more specific selector than just 'button', but have left it this way for\nsimplicity). When the button is clicked we use out getList function to refresh the grid.
\n\nYou can create any number of refs and control any number of components this way, simply adding more functions to\nyour Controller as you go. For an example of real-world usage of Controllers see the Feed Viewer example in the\nexamples/app/feed-viewer folder in the SDK download.
\n\nGenerated getter methods
\n\nRefs aren't the only thing that generate convenient getter methods. Controllers often have to deal with Models and\nStores so the framework offers a couple of easy ways to get access to those too. Let's look at another example:
\n\nExt.define('MyApp.controller.Users', {\n extend: 'Ext.app.Controller',\n\n models: ['User'],\n stores: ['AllUsers', 'AdminUsers'],\n\n init: function() {\n var User = this.getUserModel(),\n allUsers = this.getAllUsersStore();\n\n var ed = new User({name: 'Ed'});\n allUsers.add(ed);\n }\n});\n
\n\nBy specifying Models and Stores that the Controller cares about, it again dynamically loads them from the appropriate\nlocations (app/model/User.js, app/store/AllUsers.js and app/store/AdminUsers.js in this case) and creates getter\nfunctions for them all. The example above will create a new User model instance and add it to the AllUsers Store.\nOf course, you could do anything in this function but in this case we just did something simple to demonstrate the\nfunctionality.
\n\nFurther Reading
\n\nFor more information about writing Ext JS 4 applications, please see the\napplication architecture guide. Also see the Ext.app.Application documentation.
\nA config object containing one or more event handlers to be added to this object during initialization. This\nshould be a valid listeners config object as specified in the addListener example for attaching multiple\nhandlers at once.
\n\nDOM events from Ext JS Components
\n\nWhile some Ext JS Component classes export selected DOM events (e.g. \"click\", \"mouseover\" etc), this is usually\nonly done when extra value can be added. For example the DataView's itemclick
event passing the node clicked on. To access DOM events directly from a\nchild element of a Component, we need to specify the element
option to identify the Component property to add a\nDOM listener to:
new Ext.panel.Panel({\n width: 400,\n height: 200,\n dockedItems: [{\n xtype: 'toolbar'\n }],\n listeners: {\n click: {\n element: 'el', //bind to the underlying el property on the panel\n fn: function(){ console.log('click el'); }\n },\n dblclick: {\n element: 'body', //bind to the underlying body property on the panel\n fn: function(){ console.log('dblclick body'); }\n }\n }\n});\n
\nArray of models to require from AppName.model namespace. For example:
\n\nExt.define(\"MyApp.controller.Foo\", {\n extend: \"Ext.app.Controller\",\n models: ['User', 'Vehicle']\n});\n
\n\nThis is equivalent of:
\n\nExt.define(\"MyApp.controller.Foo\", {\n extend: \"Ext.app.Controller\",\n requires: ['MyApp.model.User', 'MyApp.model.Vehicle']\n});\n
\nArray of stores to require from AppName.store namespace. For example:
\n\nExt.define(\"MyApp.controller.Foo\", {\n extend: \"Ext.app.Controller\",\n stores: ['Users', 'Vehicles']\n});\n
\n\nThis is equivalent of:
\n\nExt.define(\"MyApp.controller.Foo\", {\n extend: \"Ext.app.Controller\",\n requires: ['MyApp.store.Users', 'MyApp.store.Vehicles']\n});\n
\nArray of views to require from AppName.view namespace. For example:
\n\nExt.define(\"MyApp.controller.Foo\", {\n extend: \"Ext.app.Controller\",\n views: ['List', 'Detail']\n});\n
\n\nThis is equivalent of:
\n\nExt.define(\"MyApp.controller.Foo\", {\n extend: \"Ext.app.Controller\",\n requires: ['MyApp.view.List', 'MyApp.view.Detail']\n});\n
\nGet the reference to the current class from which this object was instantiated. Unlike statics,\nthis.self
is scope-dependent and it's meant to be used for dynamic inheritance. See statics\nfor a detailed comparison
Ext.define('My.Cat', {\n statics: {\n speciesName: 'Cat' // My.Cat.speciesName = 'Cat'\n },\n\n constructor: function() {\n alert(this.self.speciesName); / dependent on 'this'\n\n return this;\n },\n\n clone: function() {\n return new this.self();\n }\n});\n\n\nExt.define('My.SnowLeopard', {\n extend: 'My.Cat',\n statics: {\n speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'\n }\n});\n\nvar cat = new My.Cat(); // alerts 'Cat'\nvar snowLeopard = new My.SnowLeopard(); // alerts 'Snow Leopard'\n\nvar clone = snowLeopard.clone();\nalert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'\n
\nAdds the specified events to the list of events which this Observable may fire.
\nEither an object with event names as properties with a value of true
or the first\nevent name string if multiple event names are being passed as separate parameters. Usage:
this.addEvents({\n storeloaded: true,\n storecleared: true\n});\n
\nAdditional event names if multiple event names are being passed as separate\nparameters. Usage:
\n\nthis.addEvents('storeloaded', 'storecleared');\n
\nAppends an event handler to this object.
\nThe name of the event to listen for. May also be an object who's property names are\nevent names.
\n\nThe method the event invokes. Will be called with arguments given to\nfireEvent plus the options
parameter described below.
The scope (this
reference) in which the handler function is executed. If\nomitted, defaults to the object which fired the event.
An object containing handler configuration.
\n\n\n\n\nNote: Unlike in ExtJS 3.x, the options object will also be passed as the last argument to every event handler.
\n\n\n\n\nThis object may contain any of the following properties:
\n\n\n\n\nscope : Object
\n\nThe scope (this
reference) in which the handler function is executed. If omitted, defaults to the object\nwhich fired the event.
delay : Number
\n\nThe number of milliseconds to delay the invocation of the handler after the event fires.
single : Boolean
\n\nTrue to add a handler to handle just the next firing of the event, and then remove itself.
buffer : Number
\n\nCauses the handler to be scheduled to run in an Ext.util.DelayedTask delayed by the specified number of\nmilliseconds. If the event fires again within that time, the original handler is not invoked, but the new\nhandler is scheduled in its place.
target : Observable
\n\nOnly call the handler if the event was fired on the target Observable, not if the event was bubbled up from a\nchild Observable.
element : String
\n\nThis option is only valid for listeners bound to Components. The name of a Component\nproperty which references an element to add a listener to.
\n\nThis option is useful during Component construction to add DOM event listeners to elements of\nComponents which will exist only after the Component is rendered.\nFor example, to add a click listener to a Panel's body:
\n\nnew Ext.panel.Panel({\n title: 'The title',\n listeners: {\n click: this.handlePanelClick,\n element: 'body'\n }\n});\n
Combining Options
\n\n\n\n\nUsing the options argument, it is possible to combine different types of listeners:
\n\n\n\n\nA delayed, one-time listener.
\n\n\n\n\nmyPanel.on('hide', this.handleClick, this, {\n single: true,\n delay: 100\n});\n
\n\n\n\n\nAttaching multiple handlers in 1 call
\n\n\n\n\nThe method also allows for a single argument to be passed which is a config object containing properties which\nspecify multiple events. For example:
\n\n\n\n\nmyGridPanel.on({\n cellClick: this.onCellClick,\n mouseover: this.onMouseOver,\n mouseout: this.onMouseOut,\n scope: this // Important. Ensure \"this\" is correct during handler execution\n});\n
\n\n\n\n\nOne can also specify options for each event handler separately:
\n\n\n\n\nmyGridPanel.on({\n cellClick: {fn: this.onCellClick, scope: this, single: true},\n mouseover: {fn: panel.onMouseOver, scope: panel}\n});\n
\n\nAdds listeners to any Observable object (or Ext.Element) which are automatically removed when this Component is\ndestroyed.
\nThe item to which to add a listener/listeners.
\n\nThe event name, or an object containing event name properties.
\n\nIf the ename
parameter was an event name, this is the handler function.
If the ename
parameter was an event name, this is the scope (this
reference)\nin which the handler function is executed.
If the ename
parameter was an event name, this is the\naddListener options.
Call the original method that was previously overridden with override
\n\nExt.define('My.Cat', {\n constructor: function() {\n alert(\"I'm a cat!\");\n\n return this;\n }\n});\n\nMy.Cat.override({\n constructor: function() {\n alert(\"I'm going to be a cat!\");\n\n var instance = this.callOverridden();\n\n alert(\"Meeeeoooowwww\");\n\n return instance;\n }\n});\n\nvar kitty = new My.Cat(); // alerts \"I'm going to be a cat!\"\n // alerts \"I'm a cat!\"\n // alerts \"Meeeeoooowwww\"\n
\nThe arguments, either an array or the arguments
object
Returns the result after calling the overridden method
\nCall the parent's overridden method. For example:
\n\nExt.define('My.own.A', {\n constructor: function(test) {\n alert(test);\n }\n});\n\nExt.define('My.own.B', {\n extend: 'My.own.A',\n\n constructor: function(test) {\n alert(test);\n\n this.callParent([test + 1]);\n }\n});\n\nExt.define('My.own.C', {\n extend: 'My.own.B',\n\n constructor: function() {\n alert(\"Going to call parent's overriden constructor...\");\n\n this.callParent(arguments);\n }\n});\n\nvar a = new My.own.A(1); // alerts '1'\nvar b = new My.own.B(1); // alerts '1', then alerts '2'\nvar c = new My.own.C(2); // alerts \"Going to call parent's overriden constructor...\"\n // alerts '2', then alerts '3'\n
\nThe arguments, either an array or the arguments
object\nfrom the current method, for example: this.callParent(arguments)
Returns the result from the superclass' method
\nRemoves all listeners for this object including the managed listeners
\nAdds listeners to components selected via Ext.ComponentQuery. Accepts an\nobject containing component paths mapped to a hash of listener functions.
\n\nIn the following example the updateUser
function is mapped to to the click
\nevent on a button component, which is a child of the useredit
component.
Ext.define('AM.controller.Users', {\n init: function() {\n this.control({\n 'useredit button[action=save]': {\n click: this.updateUser\n }\n });\n },\n\n updateUser: function(button) {\n console.log('clicked the Save button');\n }\n});\n
\n\nSee Ext.ComponentQuery for more information on component selectors.
\nEnables events fired by this Observable to bubble up an owner hierarchy by calling this.getBubbleTarget()
if\npresent. There is no implementation in the Observable base class.
This is commonly used by Ext.Components to bubble events to owner Containers.\nSee Ext.Component.getBubbleTarget. The default implementation in Ext.Component returns the\nComponent's immediate owner. But if a known target is required, this can be overridden to access the\nrequired target more quickly.
\n\nExample:
\n\nExt.override(Ext.form.field.Base, {\n // Add functionality to Field's initComponent to enable the change event to bubble\n initComponent : Ext.Function.createSequence(Ext.form.field.Base.prototype.initComponent, function() {\n this.enableBubble('change');\n }),\n\n // We know that we want Field's events to bubble directly to the FormPanel.\n getBubbleTarget : function() {\n if (!this.formPanel) {\n this.formPanel = this.findParentByType('form');\n }\n return this.formPanel;\n }\n});\n\nvar myForm = new Ext.formPanel({\n title: 'User Details',\n items: [{\n ...\n }],\n listeners: {\n change: function() {\n // Title goes red if form has been modified.\n myForm.header.setStyle('color', 'red');\n }\n }\n});\n
\nFires the specified event with the passed parameters (minus the event name, plus the options
object passed\nto addListener).
An event may be set to bubble up an Observable parent hierarchy (See Ext.Component.getBubbleTarget) by\ncalling enableBubble.
\nThe name of the event to fire.
\nVariable number of parameters are passed to handlers.
\nreturns false if any of the handlers return false otherwise it returns true.
\nReturns instance of a controller with the given name.\nWhen controller doesn't exist yet, it's created.
\na controller instance.
\nReturns a Model class with the given name.\nA shorthand for using Ext.ModelManager.getModel.
\na model class.
\nReturns instance of a Store with the given name.\nWhen store doesn't exist yet, it's created.
\na store instance.
\nA template method that is called when your application boots. It is called before the\nApplication's launch function is executed so gives a hook point to run any code before\nyour Viewport is created.
\nThis is a template method. A hook into the functionality of this class.Feel free to override it in child classes.
Initialize configuration for this class. a typical example:
\n\nExt.define('My.awesome.Class', {\n // The default config\n config: {\n name: 'Awesome',\n isAwesome: true\n },\n\n constructor: function(config) {\n this.initConfig(config);\n\n return this;\n }\n});\n\nvar awesome = new My.awesome.Class({\n name: 'Super Awesome'\n});\n\nalert(awesome.getName()); // 'Super Awesome'\n
\nmixins The mixin prototypes as key - value pairs
\nShorthand for addManagedListener.
\n\nAdds listeners to any Observable object (or Ext.Element) which are automatically removed when this Component is\ndestroyed.
\nThe item to which to add a listener/listeners.
\n\nThe event name, or an object containing event name properties.
\n\nIf the ename
parameter was an event name, this is the handler function.
If the ename
parameter was an event name, this is the scope (this
reference)\nin which the handler function is executed.
If the ename
parameter was an event name, this is the\naddListener options.
Shorthand for removeManagedListener.
\n\nRemoves listeners that were added by the mon method.
\nThe item from which to remove a listener/listeners.
\n\nThe event name, or an object containing event name properties.
\n\nIf the ename
parameter was an event name, this is the handler function.
If the ename
parameter was an event name, this is the scope (this
reference)\nin which the handler function is executed.
Shorthand for addListener.
\n\nAppends an event handler to this object.
\nThe name of the event to listen for. May also be an object who's property names are\nevent names.
\n\nThe method the event invokes. Will be called with arguments given to\nfireEvent plus the options
parameter described below.
The scope (this
reference) in which the handler function is executed. If\nomitted, defaults to the object which fired the event.
An object containing handler configuration.
\n\n\n\n\nNote: Unlike in ExtJS 3.x, the options object will also be passed as the last argument to every event handler.
\n\n\n\n\nThis object may contain any of the following properties:
\n\n\n\n\nscope : Object
\n\nThe scope (this
reference) in which the handler function is executed. If omitted, defaults to the object\nwhich fired the event.
delay : Number
\n\nThe number of milliseconds to delay the invocation of the handler after the event fires.
single : Boolean
\n\nTrue to add a handler to handle just the next firing of the event, and then remove itself.
buffer : Number
\n\nCauses the handler to be scheduled to run in an Ext.util.DelayedTask delayed by the specified number of\nmilliseconds. If the event fires again within that time, the original handler is not invoked, but the new\nhandler is scheduled in its place.
target : Observable
\n\nOnly call the handler if the event was fired on the target Observable, not if the event was bubbled up from a\nchild Observable.
element : String
\n\nThis option is only valid for listeners bound to Components. The name of a Component\nproperty which references an element to add a listener to.
\n\nThis option is useful during Component construction to add DOM event listeners to elements of\nComponents which will exist only after the Component is rendered.\nFor example, to add a click listener to a Panel's body:
\n\nnew Ext.panel.Panel({\n title: 'The title',\n listeners: {\n click: this.handlePanelClick,\n element: 'body'\n }\n});\n
Combining Options
\n\n\n\n\nUsing the options argument, it is possible to combine different types of listeners:
\n\n\n\n\nA delayed, one-time listener.
\n\n\n\n\nmyPanel.on('hide', this.handleClick, this, {\n single: true,\n delay: 100\n});\n
\n\n\n\n\nAttaching multiple handlers in 1 call
\n\n\n\n\nThe method also allows for a single argument to be passed which is a config object containing properties which\nspecify multiple events. For example:
\n\n\n\n\nmyGridPanel.on({\n cellClick: this.onCellClick,\n mouseover: this.onMouseOver,\n mouseout: this.onMouseOut,\n scope: this // Important. Ensure \"this\" is correct during handler execution\n});\n
\n\n\n\n\nOne can also specify options for each event handler separately:
\n\n\n\n\nmyGridPanel.on({\n cellClick: {fn: this.onCellClick, scope: this, single: true},\n mouseover: {fn: panel.onMouseOver, scope: panel}\n});\n
\n\nA template method like init, but called after the viewport is created.\nThis is called after the launch method of Application is executed.
\nThis is a template method. A hook into the functionality of this class.Feel free to override it in child classes.
Removes an event handler.
\nThe type of event the handler was associated with.
\n\nThe handler to remove. This must be a reference to the function passed into the\naddListener call.
\n\nThe scope originally specified for the handler. It must be the same as the\nscope argument specified in the original call to addListener or the listener will not be removed.
\n\nRemoves listeners that were added by the mon method.
\nThe item from which to remove a listener/listeners.
\n\nThe event name, or an object containing event name properties.
\n\nIf the ename
parameter was an event name, this is the handler function.
If the ename
parameter was an event name, this is the scope (this
reference)\nin which the handler function is executed.
Resumes firing events (see suspendEvents).
\n\nIf events were suspended using the queueSuspended
parameter, then all events fired\nduring event suspension will be sent to any listeners now.
Get the reference to the class from which this object was instantiated. Note that unlike self,\nthis.statics()
is scope-independent and it always returns the class from which it was called, regardless of what\nthis
points to during run-time
Ext.define('My.Cat', {\n statics: {\n totalCreated: 0,\n speciesName: 'Cat' // My.Cat.speciesName = 'Cat'\n },\n\n constructor: function() {\n var statics = this.statics();\n\n alert(statics.speciesName); // always equals to 'Cat' no matter what 'this' refers to\n // equivalent to: My.Cat.speciesName\n\n alert(this.self.speciesName); // dependent on 'this'\n\n statics.totalCreated++;\n\n return this;\n },\n\n clone: function() {\n var cloned = new this.self; // dependent on 'this'\n\n cloned.groupName = this.statics().speciesName; // equivalent to: My.Cat.speciesName\n\n return cloned;\n }\n});\n\n\nExt.define('My.SnowLeopard', {\n extend: 'My.Cat',\n\n statics: {\n speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'\n },\n\n constructor: function() {\n this.callParent();\n }\n});\n\nvar cat = new My.Cat(); // alerts 'Cat', then alerts 'Cat'\n\nvar snowLeopard = new My.SnowLeopard(); // alerts 'Cat', then alerts 'Snow Leopard'\n\nvar clone = snowLeopard.clone();\nalert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'\nalert(clone.groupName); // alerts 'Cat'\n\nalert(My.Cat.totalCreated); // alerts 3\n
\nSuspends the firing of all events. (see resumeEvents)
\nPass as true to queue up suspended events to be fired\nafter the resumeEvents call instead of discarding all suspended events.
\nShorthand for removeListener.
\n\nRemoves an event handler.
\nThe type of event the handler was associated with.
\n\nThe handler to remove. This must be a reference to the function passed into the\naddListener call.
\n\nThe scope originally specified for the handler. It must be the same as the\nscope argument specified in the original call to addListener or the listener will not be removed.
\n\nAdd / override static properties of this class.
\n\nExt.define('My.cool.Class', {\n ...\n});\n\nMy.cool.Class.addStatics({\n someProperty: 'someValue', // My.cool.Class.someProperty = 'someValue'\n method1: function() { ... }, // My.cool.Class.method1 = function() { ... };\n method2: function() { ... } // My.cool.Class.method2 = function() { ... };\n});\n
\nthis
\nBorrow another class' members to the prototype of this class.
\n\nExt.define('Bank', {\n money: '$$$',\n printMoney: function() {\n alert('$$$$$$$');\n }\n});\n\nExt.define('Thief', {\n ...\n});\n\nThief.borrow(Bank, ['money', 'printMoney']);\n\nvar steve = new Thief();\n\nalert(steve.money); // alerts '$$$'\nsteve.printMoney(); // alerts '$$$$$$$'\n
\nThe class to borrow members from
\nThe names of the members to borrow
\nthis
\nCreate a new instance of this Class.
\n\nExt.define('My.cool.Class', {\n ...\n});\n\nMy.cool.Class.create({\n someConfig: true\n});\n
\n\nAll parameters are passed to the constructor of the class.
\nthe created instance.
\nCreate aliases for existing prototype methods. Example:
\n\nExt.define('My.cool.Class', {\n method1: function() { ... },\n method2: function() { ... }\n});\n\nvar test = new My.cool.Class();\n\nMy.cool.Class.createAlias({\n method3: 'method1',\n method4: 'method2'\n});\n\ntest.method3(); // test.method1()\n\nMy.cool.Class.createAlias('method5', 'method3');\n\ntest.method5(); // test.method3() -> test.method1()\n
\nThe new method name, or an object to set multiple aliases. See\nflexSetter
\nThe original method name
\nGet the current class' name in string format.
\n\nExt.define('My.cool.Class', {\n constructor: function() {\n alert(this.self.getName()); // alerts 'My.cool.Class'\n }\n});\n\nMy.cool.Class.getName(); // 'My.cool.Class'\n
\nclassName
\nAdd methods / properties to the prototype of this class.
\n\nExt.define('My.awesome.Cat', {\n constructor: function() {\n ...\n }\n});\n\n My.awesome.Cat.implement({\n meow: function() {\n alert('Meowww...');\n }\n });\n\n var kitty = new My.awesome.Cat;\n kitty.meow();\n
\nOverride prototype members of this class. Overridden methods can be invoked via\ncallOverridden
\n\nExt.define('My.Cat', {\n constructor: function() {\n alert(\"I'm a cat!\");\n\n return this;\n }\n});\n\nMy.Cat.override({\n constructor: function() {\n alert(\"I'm going to be a cat!\");\n\n var instance = this.callOverridden();\n\n alert(\"Meeeeoooowwww\");\n\n return instance;\n }\n});\n\nvar kitty = new My.Cat(); // alerts \"I'm going to be a cat!\"\n // alerts \"I'm a cat!\"\n // alerts \"Meeeeoooowwww\"\n
\nthis
\n