Provides AJAX-style update for Element object using Yahoo
UI library YAHOO.util.Connect functionality.
Usage:
// Get it from a YAHOO.ext.Element object
var el = getEl('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 YAHOO.ext.UpdateManager('myElementId');
mgr.startAutoRefresh(60, 'http://myserver.com/index.php');
mgr.onUpdate.subscribe(myFcnNeedsToKnow);
|
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 false). |
|
el : YAHOO.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 '<div class="loading-indicator">Loading...</div>'). |
|
loadScripts : Number |
UpdateManager |
True to process scripts by default (Defaults to 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 YAHOO.ext.UpdateManager.BasicRenderer. |
|
showLoadIndicator : String |
UpdateManager |
Whether to show indicatorText when loading (Defaults to true). |
|
sslBlankUrl : String |
UpdateManager |
Blank page URL to use with SSL file uploads (Defaults to 'about:blank'). |
|
timeout : Number |
UpdateManager |
Timeout for requests or form posts in seconds (Defaults 30 seconds). |
|
transaction : Object |
UpdateManager |
YAHOO.util.Connect 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/YAHOO.ext.Element el , [Boolean forceNew ]) |
UpdateManager |
Create new UpdateManager directly. |
|
abort() : void |
UpdateManager |
Aborts the executing transaction |
|
addListener(String eventName , Function handler , [Object scope ], [boolean override ]) : void |
Observable |
Appends an event handler to this element |
|
delayedListener(String eventName , Function handler , [Object scope ], [Number delay ]) : Function |
Observable |
Appends an event handler to this element that is delayed the specified number of milliseconds. |
|
fireEvent(String eventName , Object... args ) : void |
Observable |
Fires the specified event with the passed parameters (minus the event name). |
|
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() : YAHOO.ext.Element |
UpdateManager |
Get the Element this UpdateManager is bound to |
|
isUpdating() : Boolean |
UpdateManager |
Returns true if an update is in progress |
|
purgeListeners() : void |
Observable |
Removes all listeners for this object |
|
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 |
Removes a listener |
|
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 YAHOO.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. |
|
update(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... |
|
updateElement<static>(String/HTMLElement/YAHOO.ext.Element el , String url , [String/Object params ], [Object options ]) : void |
UpdateManager |
<static> Static convenience method, Usage:
YAHOO.ext.UpdateManager.update('my-div', 'stuff.php');
|
|
beforeupdate : (YAHOO.ext.Element el , String url , String/Object params ) |
UpdateManager |
Fired before an update is made, return false from your handler and the update is cancelled. |
|
failure : (YAHOO.ext.Element el , Object oResponseObject ) |
UpdateManager |
Fired on update failure. Uses fireDirect with signature: (oElement, oResponseObject) |
|
update : (YAHOO.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 false).
This property is defined by UpdateManager.
el
public YAHOO.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 '<div class="loading-indicator">Loading...</div>').
This property is defined by UpdateManager.
loadScripts
public Number loadScripts
True to process scripts by default (Defaults to 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
This property is defined by UpdateManager.
showLoadIndicator
public String showLoadIndicator
Whether to show indicatorText when loading (Defaults to true).
This property is defined by UpdateManager.
sslBlankUrl
public String sslBlankUrl
Blank page URL to use with SSL file uploads (Defaults to 'about:blank').
This property is defined by UpdateManager.
timeout
public Number timeout
Timeout for requests or form posts in seconds (Defaults 30 seconds).
This property is defined by UpdateManager.
transaction
public Object transaction
YAHOO.util.Connect 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.
abort
public function abort()
Aborts the executing transaction
This method is defined by UpdateManager.
addListener
public function addListener(String eventName
, Function handler
, [Object scope
], [boolean override
])
Appends an event handler to this element
Parameters:
eventName
: StringThe type of event to listen for
handler
: FunctionThe method the event invokes
scope
: Object(optional) The scope (this object) for the handler
override
: boolean(optional) If true, scope becomes the scope
Returns:
delayedListener
public function delayedListener(String eventName
, Function handler
, [Object scope
], [Number delay
])
Appends an event handler to this element that is delayed the specified number of milliseconds.
Parameters:
eventName
: StringThe type of event to listen for
handler
: FunctionThe method the event invokes
scope
: Object(optional) The scope (this object) for the handler
delay
: Number(optional) The number of milliseconds to delay
Returns:
fireEvent
public function fireEvent(String eventName
, Object... args
)
Fires the specified event with the passed parameters (minus the event name).
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.
Parameters:
form
: String/HTMLElementThe form Id or form element
url
: String(optional) The url to pass the form to. If omitted the action attribute on the form will be used.
reset
: Boolean(optional) Whether to try to reset the form after the update
callback
: Function(optional) Callback when transaction is complete - called with signature (oElement, bSuccess)
Returns:
This method is defined by UpdateManager.
getEl
public function getEl()
Get the Element this UpdateManager is bound to
Parameters:
Returns:
YAHOO.ext.Element
The element
This method is defined by UpdateManager.
isUpdating
public function isUpdating()
Returns true if an update is in progress
This method is defined by UpdateManager.
purgeListeners
public function purgeListeners()
Removes all listeners for this object
refresh
public function refresh([Function callback
])
Refresh the element with the last used url or defaultUrl. If there is no url, it returns immediately
This method is defined by UpdateManager.
removeListener
public function removeListener(String eventName
, Function handler
, [Object scope
])
setDefaultUrl
public function setDefaultUrl(String/Function defaultUrl
)
Set the defaultUrl used for updates
This method is defined by UpdateManager.
setRenderer
public function setRenderer(Object renderer
)
This method is defined by UpdateManager.
showLoading
public function showLoading()
Called to update the element to "Loading" state. Override to perform custom action.
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.
Parameters:
interval
: NumberHow often to update (in seconds).
url
: String/Function(optional) The url for this request or a function to call to get the url (Defaults to the last used url)
params
: String/Object(optional) The parameters to pass as either a url encoded string "¶m1=1¶m2=2" or as an object {param1: 1, param2: 2}
callback
: Function(optional) Callback when transaction is complete - called with signature (oElement, bSuccess)
refreshNow
: Boolean(optional) Whether to execute the refresh now, or wait the interval
Returns:
This method is defined by UpdateManager.
stopAutoRefresh
public function stopAutoRefresh()
Stop auto refresh on this element.
This method is defined by UpdateManager.
update
public function update(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.
Parameters:
url
: String/FunctionThe url for this request or a function to call to get the url
params
: String/Object(optional) The parameters to pass as either a url encoded string "param1=1¶m2=2" or an object {param1: 1, param2: 2}
callback
: Function(optional) Callback when transaction is complete - called with signature (oElement, bSuccess)
discardUrl
: Boolean(optional) By default when you execute an update the defaultUrl is changed to the last used url. If true, it will not store the url.
Returns:
This method is defined by UpdateManager.
updateElement<static>
public function updateElement<static>(String/HTMLElement/YAHOO.ext.Element el
, String url
, [String/Object params
], [Object options
])
<static> Static convenience method, Usage:
YAHOO.ext.UpdateManager.update('my-div', 'stuff.php');
Parameters:
el
: String/HTMLElement/YAHOO.ext.ElementThe element to update
url
: StringThe url
params
: String/Object(optional) Url encoded param string or an object of name/value pairs
options
: Object(optional) A config object with any of the UpdateManager properties you want to set - for example: {disableCaching:true, indicatorText: 'Loading data...'}
Returns:
This method is defined by UpdateManager.