| Package: | Ext.data |
| Class: | Connection |
| Extends: | Observable |
| Subclasses: | Ajax |
| Defined In: | Connection.js |
Requests made by this class are asynchronous, and will return immediately. No data from the server will be available to the statement immediately following the request call. To process returned data, use a callback in the request options object.
| Method | Defined By | |
|---|---|---|
Connection(config {Object}) |
Connection | |
abort([Number transactionId]) : void |
Connection | |
| Aborts any outstanding request. | ||
addEvents(Object object) : void |
Observable | |
| Used to define events on this Observable | ||
addListener(String eventName, Function handler, [Object scope], [Object options]) : void |
Observable | |
| Appends an event handler to this component | ||
fireEvent(String eventName, Object... args) : Boolean |
Observable | |
| Fires the specified event with the passed parameters (minus the event name). | ||
hasListener(String eventName) : Boolean |
Observable | |
| Checks to see if this object has any listeners for a specified event | ||
isLoading([Number transactionId]) : Boolean |
Connection | |
| Determine whether this object has a request outstanding. | ||
on(String eventName, Function handler, [Object scope], [Object options]) : void |
Observable | |
| Appends an event handler to this element (shorthand for addListener) | ||
| purgeListeners() : void | Observable | |
| Removes all listeners for this object | ||
removeListener(String eventName, Function handler, [Object scope]) : void |
Observable | |
| Removes a listener | ||
request([Object options]) : Number |
Connection | |
| Sends an HTTP request to a remote server. | ||
un(String eventName, Function handler, [Object scope]) : void |
Observable | |
| Removes a listener (shorthand for removeListener) | ||
| Event | Defined By | |
|---|---|---|
beforerequest : (Connection conn, Object options) |
Connection | |
| Fires before a network request is made to retrieve a data object. | ||
requestcomplete : (Connection conn, Object response, Object options) |
Connection | |
| Fires before a network request is made to retrieve a data object. | ||
requestexception : (Connection conn, Object response, Object options) |
Connection | |
| Fires if an error HTTP status was returned from the server. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.htm... | ||
| Config Options | Defined By | |
|---|---|---|
| defaultHeaders : Object | Connection | |
| (Optional) An object containing request headers which are added to each request made by this object. | ||
| extraParams : Object | Connection | |
| (Optional) An object containing properties which are used as extra parameters to each request made by this object. | ||
| method : String | Connection | |
| (Optional) The default HTTP method to be used for requests. | ||
| timeout : Number | Connection | |
| (Optional) The timeout in milliseconds to be used for requests. Defaults to 30000. | ||
| url : String | Connection | |
| (Optional) The default URL to be used for requests to the server. | ||
public function Connection(config {Object})
{Object} : configpublic function abort([Number transactionId])
transactionId : Numbervoidpublic function addEvents(Object object)
object : Objectvoidpublic function addListener(String eventName, Function handler, [Object scope], [Object options])
eventName : Stringhandler : Functionscope : Objectoptions : Object Combining Options
Using the options argument, it is possible to combine different types of listeners:
A normalized, delayed, one-time listener that auto stops the event and passes a custom argument (forumId)
el.on('click', this.onClick, this, { single: true, delay: 100, forumId: 4 }); Attaching multiple handlers in 1 call
The method also allows for a single argument to be passed which is a config object containing properties which specify multiple handlers.
Code:
foo.on({ 'click' : { fn: this.onClick scope: this, delay: 100 }, 'mouseover' : { fn: this.onMouseOver scope: this }, 'mouseout' : { fn: this.onMouseOut scope: this } }); Or a shorthand syntax:
Code:
foo.on({ 'click' : this.onClick, 'mouseover' : this.onMouseOver, 'mouseout' : this.onMouseOut scope: this });voidpublic function fireEvent(String eventName, Object... args)
eventName : Stringargs : Object...Booleanpublic function hasListener(String eventName)
eventName : StringBooleanpublic function isLoading([Number transactionId])
transactionId : NumberBooleanpublic function on(String eventName, Function handler, [Object scope], [Object options])
eventName : Stringhandler : Functionscope : Objectoptions : Objectvoidpublic function purgeListeners()
voidpublic function removeListener(String eventName, Function handler, [Object scope])
eventName : Stringhandler : Functionscope : Objectvoidpublic function request([Object options])
options : ObjectNumberpublic function un(String eventName, Function handler, [Object scope])
eventName : Stringhandler : Functionscope : Objectvoidpublic event beforerequest
conn : Connectionoptions : Objectpublic event requestcomplete
conn : Connectionresponse : Objectoptions : Objectpublic event requestexception
conn : Connectionresponse : Objectoptions : ObjectdefaultHeaders : Object
extraParams : Object
method : String
timeout : Number
url : String