打印版式

Class Ext.UpdateManager

Package:Ext
Class:UpdateManager
Extends:Observable
Defined In:UpdateManager.js
Provides AJAX-style update for Element object.

Usage:
// 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&param2=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.

属性详情

defaultUrl

public String defaultUrl
Cached url to use for refreshes. Overwritten every time update() is called unless "discardUrl" param is set to true.
This property is defined by UpdateManager.

disableCaching

public Boolean disableCaching
Whether to append unique parameter on get request to disable caching (Defaults to Ext.UpdateManager.defaults.disableCaching or false).
This property is defined by UpdateManager.

el

public Ext.Element el
The Element object
This property is defined by UpdateManager.

formUpdateDelegate

public Function formUpdateDelegate
Delegate for formUpdate() prebound to "this", use myUpdater.formUpdateDelegate.createCallback(arg1, arg2) to bind arguments
This property is defined by UpdateManager.

indicatorText

public String indicatorText
Text for loading indicator (Defaults to Ext.UpdateManager.defaults.indicatorText or '<div class="loading-indicator">Loading...</div>').
This property is defined by UpdateManager.

loadScripts

public Boolean loadScripts
True to process scripts in the output (Defaults to Ext.UpdateManager.defaults.loadScripts (false)).
This property is defined by UpdateManager.

refreshDelegate

public Function refreshDelegate
Delegate for refresh() prebound to "this", use myUpdater.refreshDelegate.createCallback(arg1, arg2) to bind arguments
This property is defined by UpdateManager.

renderer

public Object renderer
The renderer for this UpdateManager. Defaults to Ext.UpdateManager.BasicRenderer.
This property is defined by UpdateManager.

showLoadIndicator

public String showLoadIndicator
Whether to show indicatorText when loading (Defaults to Ext.UpdateManager.defaults.showLoadIndicator or true).
This property is defined by UpdateManager.

sslBlankUrl

public String sslBlankUrl
Blank page URL to use with SSL file uploads (Defaults to Ext.UpdateManager.defaults.sslBlankUrl or "about:blank").
This property is defined by UpdateManager.

timeout

public Number timeout
Timeout for requests or form posts in seconds (Defaults to Ext.UpdateManager.defaults.timeout or 30 seconds).
This property is defined by UpdateManager.

transaction

public Object transaction
Transaction object of current executing transaction
This property is defined by UpdateManager.

updateDelegate

public Function updateDelegate
Delegate for update() prebound to "this", use myUpdater.updateDelegate.createCallback(arg1, arg2) to bind arguments
This property is defined by UpdateManager.

构造函数

UpdateManager

public function UpdateManager(String/HTMLElement/Ext.Element el, [Boolean forceNew])
Create new UpdateManager directly.
参数:
  • el : String/HTMLElement/Ext.Element
    The element to update
  • forceNew : Boolean
    (可选) By default the constructor checks to see if the passed element already has an UpdateManager and if it does it returns the same instance. This will skip that check (useful for extending this class).

方法详情

UpdateManager.updateElement

public function UpdateManager.updateElement(String/HTMLElement/Ext.Element el, String url, [String/Object params], [Object options])
Deprecated. <static> Static convenience method. This method is deprecated in favor of el.load({url:'foo.php', ...}). Usage:
Ext.UpdateManager.updateElement("my-div", "stuff.php");
参数:
  • el : String/HTMLElement/Ext.Element
    The element to update
  • url : String
    The url
  • params : String/Object
    (可选) Url encoded param string or an object of name/value pairs
  • options : Object
    (可选) A config object with any of the UpdateManager properties you want to set - for example: {disableCaching:true, indicatorText: "Loading data..."}
返回:
  • void
This method is defined by UpdateManager.

abort

public function abort()
Aborts the executing transaction
参数:
  • 无。
返回:
  • void
This method is defined by UpdateManager.

addEvents

public function addEvents(Object object)
将对象中没有的事件从给出的对象中复制过来。给出的对象必须也继承于 Observable 对象此方法才会有效果。
参数:
  • object : Object
    要复制事件的源对象
返回:
  • void
This method is defined by Observable.

addListener

public function addListener(String eventName, Function handler, [Object scope], [Object options])
为组件添加一个事件监听器
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    事件调用的方法
  • scope : Object
    (可选)处理函数执行的作用域。处理函数 "this" 的内容。
  • options : Object
    (可选)一个包含处理设置属性的对象。可以包含下列的属性:
    • scope {Object} 处理函数执行的作用域。处理函数 "this" 的内容。
    • delegate {String} 一个简单的选择器用来过滤目标或查找目标的子节点。
    • stopEvent {Boolean} 值为 True 时用来中止事件。那样将中止传播,并防止缺省动作。
    • preventDefault {Boolean} 值为 True 时用来防止缺省动作。
    • stopPropagation {Boolean} 值为 True 时用来中止事件传播。
    • normalized {Boolean} 值为 False 时向处理函数传递浏览器事件用以代替 Ext.EventObject 对象。
    • delay {Number} 当事件触发后启用处理函数的延迟微秒数。
    • single {Boolean} 值为 True 时将添加一个处理函数用来处理下个触发的事件,并在处理完后移除。
    • buffer {Number} 使处理函数计划在由 Ext.util.DelayedTask 指定的微秒数后执行。如果事件在延迟期间再次触发,原来的处理函数将不再启动,而是由新的计划代替。

    组合选项
    使用选项参数可以组合不同类型的监听器:

    下面是一个标准的、延迟执行的、一次性的监听器,将会自动停止事件并传递一个自定义的参数(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
This method is defined by Observable.

fireEvent

public function fireEvent(String eventName, Object... args)
触发指定的事件并给出参数(至少要有事件名称)。
参数:
  • eventName : String
  • args : Object...
    传入处理函数的参数
返回:
  • Boolean
    如果任何处理函数返回 false 则返回值为 false, 否则返回 true。
This method is defined by Observable.

formUpdate

public function formUpdate(String/HTMLElement form, [String url], [Boolean reset], [Function callback])
Performs an async form post, updating this element with the response. If the form has the attribute enctype="multipart/form-data", it assumes it's a file upload. Uses this.sslBlankUrl for SSL file uploads to prevent IE security warning. See YUI docs for more info.
参数:
  • form : String/HTMLElement
    The form Id or form element
  • url : String
    (可选) The url to pass the form to. If omitted the action attribute on the form will be used.
  • reset : Boolean
    (可选) Whether to try to reset the form after the update
  • callback : Function
    (可选) Callback when transaction is complete - called with signature (oElement, bSuccess, oResponse)
返回:
  • void
This method is defined by UpdateManager.

getEl

public function getEl()
Get the Element this UpdateManager is bound to
参数:
  • 无。
返回:
  • Ext.Element
    The element
This method is defined by UpdateManager.

hasListener

public function hasListener(String eventName)
检查该对象是否拥有指定事件的侦听器
参数:
  • eventName : String
    查询事件之名称
返回:
  • Boolean
    值为 True 值表示事件监听器存在, 否则值为 false。
This method is defined by Observable.

isUpdating

public function isUpdating()
Returns true if an update is in progress
参数:
  • 无。
返回:
  • Boolean
This method is defined by UpdateManager.

on

public function on(String eventName, Function handler, [Object options])
为该组件加入事件处理器函数, addListener 的简写方式
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    事件调用的方法
  • options : Object
    (可选)
返回:
  • void
This method is defined by Observable.

purgeListeners

public function purgeListeners()
从对象身上移除所有的侦听器
参数:
  • 无。
返回:
  • void
This method is defined by Observable.

refresh

public function refresh([Function callback])
Refresh the element with the last used url or defaultUrl. If there is no url, it returns immediately
参数:
  • callback : Function
    (可选) Callback when transaction is complete - called with signature (oElement, bSuccess)
返回:
  • void
This method is defined by UpdateManager.

removeListener

public function removeListener(String eventName, Function handler, [Object scope])
移除侦听器
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    删除的处理函数
  • scope : Object
    (可选) The scope (this object) for the handler
返回:
  • void
This method is defined by Observable.

setDefaultUrl

public function setDefaultUrl(String/Function defaultUrl)
Set the defaultUrl used for updates
参数:
  • defaultUrl : String/Function
    The url or a function to call to get the url
返回:
  • void
This method is defined by UpdateManager.

setRenderer

public function setRenderer(Object renderer)
Set the content renderer for this UpdateManager. See Ext.UpdateManager.BasicRenderer.render for more details.
参数:
  • renderer : Object
    The object implementing the render() method
返回:
  • void
This method is defined by UpdateManager.

showLoading

public function showLoading()
Called to update the element to "Loading" state. Override to perform custom action.
参数:
  • 无。
返回:
  • void
This method is defined by UpdateManager.

startAutoRefresh

public function startAutoRefresh(Number interval, [String/Function url], [String/Object params], [Function callback], [Boolean refreshNow])
Set this element to auto refresh.
参数:
  • interval : Number
    How often to update (in seconds).
  • url : String/Function
    (可选) The url for this request or a function to call to get the url (Defaults to the last used url)
  • params : String/Object
    (可选) The parameters to pass as either a url encoded string "¶m1=1¶m2=2" or as an object {param1: 1, param2: 2}
  • callback : Function
    (可选) Callback when transaction is complete - called with signature (oElement, bSuccess)
  • refreshNow : Boolean
    (可选) Whether to execute the refresh now, or wait the interval
返回:
  • void
This method is defined by UpdateManager.

stopAutoRefresh

public function stopAutoRefresh()
Stop auto refresh on this element.
参数:
  • 无。
返回:
  • void
This method is defined by UpdateManager.

un

public function un(String eventName, Function handler, [Object scope])
移除侦听器, removeListener 的简写方式
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    删除的处理函数
  • scope : Object
    (可选) The scope (this object) for the handler
返回:
  • void
This method is defined by Observable.

update

public function update(Object/String/Function url, [String/Object params], [Function callback], [Boolean discardUrl])
Performs an async request, updating this element with the response. If params are specified it uses POST, otherwise it uses GET.
参数:
  • url : Object/String/Function
    The url for this request or a function to call to get the url or a config object containing any of the following options:
     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/Object
    (可选) The parameters to pass as either a url encoded string "param1=1&param2=2" or an object {param1: 1, param2: 2}
  • callback : Function
    (可选) Callback when transaction is complete - called with signature (oElement, bSuccess, oResponse)
  • discardUrl : Boolean
    (可选) By default when you execute an update the defaultUrl is changed to the last used url. If true, it will not store the url.
返回:
  • void
This method is defined by UpdateManager.

事件详情

beforeupdate

public event beforeupdate
Fired before an update is made, return false from your handler and the update is cancelled.
Subscribers will be called with the following parameters:
  • el : Ext.Element
  • url : String/Object/Function
  • params : String/Object
This event is defined by UpdateManager.

failure

public event failure
Fired on update failure.
Subscribers will be called with the following parameters:
  • el : Ext.Element
  • oResponseObject : Object
    The response Object
This event is defined by UpdateManager.

update

public event update
Fired after successful update is made.
Subscribers will be called with the following parameters:
  • el : Ext.Element
  • oResponseObject : Object
    The response Object
This event is defined by UpdateManager.

Ext - Copyright © 2006-2007 Ext JS, LLC
All rights reserved.