Package: | Ext |
Class: | UpdateManager |
Extends: | Observable |
Defined In: | UpdateManager.js |
// Get it from a Ext.Element object
var el = Ext.get("foo");
var mgr = el.getUpdateManager();
mgr.update("http://myserver.com/index.php", "param1=1¶m2=2");
...
mgr.formUpdate("myFormId", "http://myserver.com/index.php");
// or directly (returns the same UpdateManager instance)
var mgr = new Ext.UpdateManager("myElementId");
mgr.startAutoRefresh(60, "http://myserver.com/index.php");
mgr.on("update", myFcnNeedsToKnow);
// short handed call directly from the element object
Ext.get("foo").load({
url: "bar.php",
scripts:true,
params: "for=bar",
text: "Loading Foo..."
});
属性 | 定义对象 | |
---|---|---|
defaultUrl : String | UpdateManager | |
Cached url to use for refreshes. Overwritten every time update() is called unless "discardUrl" param is set to true. | ||
disableCaching : Boolean | UpdateManager | |
Whether to append unique parameter on get request to disable caching (Defaults to Ext.UpdateManager.defaults.disableC... | ||
el : Ext.Element | UpdateManager | |
The Element object | ||
formUpdateDelegate : Function | UpdateManager | |
Delegate for formUpdate() prebound to "this", use myUpdater.formUpdateDelegate.createCallback(arg1, arg2) to bind arg... | ||
indicatorText : String | UpdateManager | |
Text for loading indicator (Defaults to Ext.UpdateManager.defaults.indicatorText or '<div class="loading-indicator... | ||
loadScripts : Boolean | UpdateManager | |
True to process scripts in the output (Defaults to Ext.UpdateManager.defaults.loadScripts (false)). | ||
refreshDelegate : Function | UpdateManager | |
Delegate for refresh() prebound to "this", use myUpdater.refreshDelegate.createCallback(arg1, arg2) to bind arguments | ||
renderer : Object | UpdateManager | |
The renderer for this UpdateManager. Defaults to Ext.UpdateManager.BasicRenderer. | ||
showLoadIndicator : String | UpdateManager | |
Whether to show indicatorText when loading (Defaults to Ext.UpdateManager.defaults.showLoadIndicator or true). | ||
sslBlankUrl : String | UpdateManager | |
Blank page URL to use with SSL file uploads (Defaults to Ext.UpdateManager.defaults.sslBlankUrl or "about:blank"). | ||
timeout : Number | UpdateManager | |
Timeout for requests or form posts in seconds (Defaults to Ext.UpdateManager.defaults.timeout or 30 seconds). | ||
transaction : Object | UpdateManager | |
Transaction object of current executing transaction | ||
updateDelegate : Function | UpdateManager | |
Delegate for update() prebound to "this", use myUpdater.updateDelegate.createCallback(arg1, arg2) to bind arguments |
方法 | 定义对象 | |
---|---|---|
UpdateManager(String/HTMLElement/Ext.Element el , [Boolean forceNew ]) |
UpdateManager | |
Create new UpdateManager directly. | ||
UpdateManager.updateElement(String/HTMLElement/Ext.Element el , String url , [String/Object params ], [Object options ]) : void |
UpdateManager | |
Deprecated. <static> Static convenience method. This method is deprecated in favor of el.load({url:'foo.php', .... | ||
abort() : void | UpdateManager | |
Aborts the executing transaction | ||
addEvents(Object object ) : void |
Observable | |
将对象中没有的事件从给出的对象中复制过来。 | ||
addListener(String eventName , Function handler , [Object scope ], [Object options ]) : void |
Observable | |
为该组件加入事件处理器函数 | ||
fireEvent(String eventName , Object... args ) : Boolean |
Observable | |
触发指定的事件, 并将参数传入(至少要有事件名称)。 | ||
formUpdate(String/HTMLElement form , [String url ], [Boolean reset ], [Function callback ]) : void |
UpdateManager | |
Performs an async form post, updating this element with the response. If the form has the attribute enctype="multipar... | ||
getEl() : Ext.Element | UpdateManager | |
Get the Element this UpdateManager is bound to | ||
hasListener(String eventName ) : Boolean |
Observable | |
检查该对象是否拥有指定事件的侦听器 | ||
isUpdating() : Boolean | UpdateManager | |
Returns true if an update is in progress | ||
on(String eventName , Function handler , [Object options ]) : void |
Observable | |
为该组件加入事件处理器函数, addListener 的简写方式 | ||
purgeListeners() : void | Observable | |
从对象身上移除所有的侦听器 | ||
refresh([Function callback ]) : void |
UpdateManager | |
Refresh the element with the last used url or defaultUrl. If there is no url, it returns immediately | ||
removeListener(String eventName , Function handler , [Object scope ]) : void |
Observable | |
移除侦听器 | ||
setDefaultUrl(String/Function defaultUrl ) : void |
UpdateManager | |
Set the defaultUrl used for updates | ||
setRenderer(Object renderer ) : void |
UpdateManager | |
Set the content renderer for this UpdateManager. See Ext.UpdateManager.BasicRenderer.render for more details. | ||
showLoading() : void | UpdateManager | |
Called to update the element to "Loading" state. Override to perform custom action. | ||
startAutoRefresh(Number interval , [String/Function url ], [String/Object params ], [Function callback ], [Boolean refreshNow ]) : void |
UpdateManager | |
Set this element to auto refresh. | ||
stopAutoRefresh() : void | UpdateManager | |
Stop auto refresh on this element. | ||
un(String eventName , Function handler , [Object scope ]) : void |
Observable | |
移除侦听器, removeListener 的简写方式 | ||
update(Object/String/Function url , [String/Object params ], [Function callback ], [Boolean discardUrl ]) : void |
UpdateManager | |
Performs an async request, updating this element with the response. If params are specified it uses POST, otherwise i... |
事件 | 定义对象 | |
---|---|---|
beforeupdate : (Ext.Element el , String/Object/Function url , String/Object params ) |
UpdateManager | |
Fired before an update is made, return false from your handler and the update is cancelled. | ||
failure : (Ext.Element el , Object oResponseObject ) |
UpdateManager | |
Fired on update failure. | ||
update : (Ext.Element el , Object oResponseObject ) |
UpdateManager | |
Fired after successful update is made. |
public String defaultUrl
public Boolean disableCaching
public Ext.Element el
public Function formUpdateDelegate
public String indicatorText
public Boolean loadScripts
public Function refreshDelegate
public Object renderer
public String showLoadIndicator
public String sslBlankUrl
public Number timeout
public Object transaction
public Function updateDelegate
public function UpdateManager(String/HTMLElement/Ext.Element el
, [Boolean forceNew
])
el
: String/HTMLElement/Ext.ElementforceNew
: Booleanpublic function UpdateManager.updateElement(String/HTMLElement/Ext.Element el
, String url
, [String/Object params
], [Object options
])
Ext.UpdateManager.updateElement("my-div", "stuff.php");
el
: String/HTMLElement/Ext.Elementurl
: Stringparams
: String/Objectoptions
: Objectvoid
public function abort()
void
public function addEvents(Object object
)
object
: Objectvoid
public function addListener(String eventName
, Function handler
, [Object scope
], [Object options
])
eventName
: Stringhandler
: Functionscope
: Objectoptions
: Object
组合选项
使用选项参数可以组合不同类型的监听器:
下面是一个标准的、延迟执行的、一次性的监听器,将会自动停止事件并传递一个自定义的参数(forumId)
el.on('click', this.onClick, this, { single: true, delay: 100, stopEvent : true, forumId: 4 });
这个方法也允许传递的单个参数是一个包含多个指定处理函数的设置对象。
一次调用多个处理函数
代码:
el.on({ 'click' : { fn: this.onClick scope: this, delay: 100 }, 'mouseover' : { fn: this.onMouseOver scope: this }, 'mouseout' : { fn: this.onMouseOut scope: this } });
或者简写为:
代码:
el.on({ 'click' : this.onClick, 'mouseover' : this.onMouseOver, 'mouseout' : this.onMouseOut scope: this });
void
public function fireEvent(String eventName
, Object... args
)
eventName
: Stringargs
: Object...Boolean
public function formUpdate(String/HTMLElement form
, [String url
], [Boolean reset
], [Function callback
])
form
: String/HTMLElementurl
: Stringreset
: Booleancallback
: Functionvoid
public function getEl()
Ext.Element
public function hasListener(String eventName
)
eventName
: StringBoolean
public function isUpdating()
Boolean
public function on(String eventName
, Function handler
, [Object options
])
eventName
: Stringhandler
: Functionoptions
: Objectvoid
public function purgeListeners()
void
public function refresh([Function callback
])
callback
: Functionvoid
public function removeListener(String eventName
, Function handler
, [Object scope
])
eventName
: Stringhandler
: Functionscope
: Objectvoid
public function setDefaultUrl(String/Function defaultUrl
)
defaultUrl
: String/Functionvoid
public function setRenderer(Object renderer
)
renderer
: Objectvoid
public function showLoading()
void
public function startAutoRefresh(Number interval
, [String/Function url
], [String/Object params
], [Function callback
], [Boolean refreshNow
])
interval
: Numberurl
: String/Functionparams
: String/Objectcallback
: FunctionrefreshNow
: Booleanvoid
public function stopAutoRefresh()
void
public function un(String eventName
, Function handler
, [Object scope
])
eventName
: Stringhandler
: Functionscope
: Objectvoid
public function update(Object/String/Function url
, [String/Object params
], [Function callback
], [Boolean discardUrl
])
url
: Object/String/Function um.update({
url: "your-url.php",
params: {param1: "foo", param2: "bar"}, // or a URL encoded string
callback: yourFunction,
scope: yourObject, //(optional scope)
discardUrl: false,
nocache: false,
text: "Loading...",
timeout: 30,
scripts: false
});
The only required property is url. The optional properties nocache, text and scripts are shorthand for disableCaching, indicatorText and loadScripts and are used to set their associated property on this UpdateManager instance.params
: String/Objectcallback
: FunctiondiscardUrl
: Booleanvoid
public event beforeupdate
el
: Ext.Elementurl
: String/Object/Functionparams
: String/Objectpublic event failure
el
: Ext.ElementoResponseObject
: Objectpublic event update
el
: Ext.ElementoResponseObject
: Object