AjaxHelper Class Reference

Public Member Functions | |
| _buildCallbacks ($options) | |
| _buildObserver ($klass, $name, $options=null) | |
| _buildOptions ($options, $acceptable) | |
| _optionsToString ($options, $stringOpts=array()) | |
| afterRender () | |
| autoComplete ($field, $url="", $options=array()) | |
| div ($id, $options=array()) | |
| divEnd ($id) | |
| drag ($id, $options=array()) | |
| drop ($id, $options=array()) | |
| dropRemote ($id, $options=array(), $ajaxOptions=array()) | |
| editor ($id, $url, $options=array()) | |
| form ($params=null, $type= 'post', $options=array()) | |
| isAjax () | |
| link ($title, $href=null, $options=array(), $confirm=null, $escapeTitle=true) | |
| observeField ($field, $options=array()) | |
| observeForm ($form, $options=array()) | |
| remoteFunction ($options) | |
| remoteTimer ($options=null) | |
| slider ($id, $trackId, $options=array()) | |
| sortable ($id, $options=array()) | |
| submit ($title= 'Submit', $options=array()) | |
Public Attributes | |
| $ajaxOptions = array('after', 'asynchronous', 'before', 'confirm', 'condition', 'contentType', 'encoding', 'evalScripts', 'failure', 'fallback', 'form', 'indicator', 'insertion', 'interactive', 'loaded', 'loading', 'method', 'onCreate', 'onComplete', 'onException', 'onFailure', 'onInteractive', 'onLoaded', 'onLoading', 'onSuccess', 'onUninitialized', 'parameters', 'position', 'postBody', 'requestHeaders', 'success', 'type', 'update', 'with') | |
| $autoCompleteOptions = array('afterUpdateElement', 'callback', 'frequency', 'indicator', 'minChars', 'onShow', 'onHide', 'parameters', 'paramName', 'tokens', 'updateElement') | |
| $callbacks = array('complete', 'create', 'exception', 'failure', 'interactive', 'loading', 'loaded', 'success', 'uninitialized') | |
| $dragOptions = array('handle', 'revert', 'snap', 'zindex', 'constraint', 'change', 'ghosting', 'starteffect', 'reverteffect', 'endeffect') | |
| $dropOptions = array('accept', 'containment', 'greedy', 'hoverclass', 'onHover', 'onDrop', 'overlap') | |
| $editorOptions = array('okText', 'cancelText', 'savingText', 'formId', 'externalControl', 'rows', 'cols', 'size', 'highlightcolor', 'highlightendcolor', 'savingClassName', 'formClassName', 'loadTextURL', 'loadingText', 'callback', 'ajaxOptions', 'clickToEditText', 'collection', 'okButton', 'cancelLink') | |
| $helpers = array('Html', 'Javascript', 'Form') | |
| $Html = null | |
| $Javascript = null | |
| $sliderOptions = array('alignX', 'alignY', 'axis', 'disabled', 'handleDisabled', 'handleImage', 'increment', 'maximum', 'minimum', 'onChange', 'onSlide', 'range', 'sliderValue', 'values') | |
| $sortOptions = array('constraint', 'containment', 'dropOnEmpty', 'ghosting', 'handle', 'hoverclass', 'onUpdate', 'onChange', 'only', 'overlap', 'scroll', 'scrollSensitivity', 'scrollSpeed', 'tag', 'tree', 'treeTag', 'update') | |
Detailed Description
Definition at line 39 of file ajax.php.
Member Function Documentation
| AjaxHelper::_buildCallbacks | ( | $ | options | ) |
Return Javascript text for callbacks.
- Parameters:
-
array $options Option array where a callback is specified
- Returns:
- array Options with their callbacks properly set protected
Definition at line 783 of file ajax.php.
References $callbacks.
Referenced by sortable().
| AjaxHelper::_buildObserver | ( | $ | klass, | |
| $ | name, | |||
| $ | options = null | |||
| ) |
Return JavaScript text for an observer...
- Parameters:
-
string $klass Name of JavaScript class string $name array $options Ajax options
- Returns:
- string Formatted JavaScript
Definition at line 765 of file ajax.php.
References remoteFunction(), and Helper::value().
Referenced by observeField(), and observeForm().
| AjaxHelper::_buildOptions | ( | $ | options, | |
| $ | acceptable | |||
| ) |
Returns a string of JavaScript with the given option data as a JavaScript options hash.
- Parameters:
-
array $options Options in the shape of keys and values array $acceptable Array of legal keys in this options context
- Returns:
- string String of Javascript array definition
Definition at line 735 of file ajax.php.
References $out.
Referenced by autoComplete(), drag(), drop(), dropRemote(), editor(), slider(), and sortable().
| AjaxHelper::_optionsToString | ( | $ | options, | |
| $ | stringOpts = array() | |||
| ) |
Returns a string of JavaScript with a string representation of given options array.
- Parameters:
-
array $options Ajax options array array $stringOpts Options as strings in an array private
- Returns:
- array
Definition at line 821 of file ajax.php.
Referenced by autoComplete(), drag(), drop(), dropRemote(), editor(), slider(), and sortable().
| AjaxHelper::afterRender | ( | ) |
Executed after a view has rendered, used to include bufferred code blocks.
public
Reimplemented from Helper.
Definition at line 841 of file ajax.php.
References Helper::$data, $out, Object::_stop(), e(), and env().
| AjaxHelper::autoComplete | ( | $ | field, | |
| $ | url = "", |
|||
| $ | options = array() | |||
| ) |
Create a text field with Autocomplete.
Creates an autocomplete field with the given ID and options.
options['with'] defaults to "Form.Element.serialize('$field')", but can be any valid javascript expression defining the
- Parameters:
-
string $field DOM ID of field to observe string $url URL for the autocomplete action array $options Ajax options
- Returns:
- string Ajax script
Definition at line 398 of file ajax.php.
References $url, _buildOptions(), _optionsToString(), and Inflector::camelize().
| AjaxHelper::div | ( | $ | id, | |
| $ | options = array() | |||
| ) |
Creates an Ajax-updateable DIV element
- Parameters:
-
string $id options for javascript
- Returns:
- string HTML code
Definition at line 445 of file ajax.php.
References Helper::_parseAttributes(), env(), and Helper::output().
| AjaxHelper::divEnd | ( | $ | id | ) |
Closes an Ajax-updateable DIV element
- Parameters:
-
string $id The DOM ID of the element
- Returns:
- string HTML code
Definition at line 465 of file ajax.php.
References env(), and Helper::output().
| AjaxHelper::drag | ( | $ | id, | |
| $ | options = array() | |||
| ) |
Creates a draggable element. For a reference on the options for this function, check out http://wiki.script.aculo.us/scriptaculous/show/Draggable
- Parameters:
-
unknown_type $id array $options
- Returns:
- unknown
Definition at line 493 of file ajax.php.
References _buildOptions(), and _optionsToString().
| AjaxHelper::drop | ( | $ | id, | |
| $ | options = array() | |||
| ) |
For a reference on the options for this function, check out http://wiki.script.aculo.us/scriptaculous/show/Droppables.add
- Parameters:
-
unknown_type $id array $options
- Returns:
- string
Definition at line 510 of file ajax.php.
References _buildOptions(), and _optionsToString().
| AjaxHelper::dropRemote | ( | $ | id, | |
| $ | options = array(), |
|||
| $ | ajaxOptions = array() | |||
| ) |
Make an element with the given $id droppable, and trigger an Ajax call when a draggable is dropped on it.
For a reference on the options for this function, check out http://wiki.script.aculo.us/scriptaculous/show/Droppables.add
- Parameters:
-
string $id array $options array $ajaxOptions
- Returns:
- string JavaScript block to create a droppable element
Definition at line 532 of file ajax.php.
References $ajaxOptions, _buildOptions(), _optionsToString(), and remoteFunction().
| AjaxHelper::editor | ( | $ | id, | |
| $ | url, | |||
| $ | options = array() | |||
| ) |
Makes an Ajax In Place editor control.
- Parameters:
-
string $id DOM ID of input element string $url Postback URL of saved data array $options Array of options to control the editor, including ajaxOptions (see link). http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor
Definition at line 584 of file ajax.php.
References $url, _buildOptions(), _optionsToString(), form(), Helper::url(), and Helper::value().
| AjaxHelper::form | ( | $ | params = null, |
|
| $ | type = 'post', |
|||
| $ | options = array() | |||
| ) |
Returns form tag that will submit using Ajax.
Returns a form tag that will submit using XMLHttpRequest in the background instead of the regular reloading POST arrangement. Even though it's using Javascript to serialize the form elements, the form submission will work just like a regular submission as viewed by the receiving side (all elements available in params). The options for defining callbacks is the same as link().
- Parameters:
-
array $params Form target array $type How form data is posted: 'get' or 'post' array $options Callback/HTML options
- Returns:
- string JavaScript/HTML code
Definition at line 280 of file ajax.php.
References Helper::$params, Helper::model(), remoteFunction(), submit(), and Helper::url().
Referenced by editor(), and sortable().
| AjaxHelper::isAjax | ( | ) |
| AjaxHelper::link | ( | $ | title, | |
| $ | href = null, |
|||
| $ | options = array(), |
|||
| $ | confirm = null, |
|||
| $ | escapeTitle = true | |||
| ) |
Returns link to remote action
Returns a link to a remote action defined by options[url] (using the url() format) that's called in the background using XMLHttpRequest. The result of that request can then be inserted into a DOM object whose id can be specified with options[update].
Examples: link("Delete this post", array("update" => "posts", "url" => "delete/{$postid->id}")); link(imageTag("refresh"), array("update" => "emails", "url" => "list_emails" ));
By default, these remote requests are processed asynchronous during which various callbacks can be triggered (for progress indicators and the likes).
Example: link (word, array("url" => "undo", "n" => word_counter), array("complete" => "undoRequestCompleted(request)"));
The callbacks that may be specified are:
- loading:: Called when the remote document is being loaded with data by the browser.
- loaded:: Called when the browser has finished loading the remote document.
- interactive:: Called when the user can interact with the remote document, even though it has not finished loading.
- complete:: Called when the XMLHttpRequest is complete.
If you for some reason or another need synchronous processing (that'll block the browser while the request is happening), you can specify options[type] = synchronous.
You can customize further browser side call logic by passing in Javascript code snippets via some optional parameters. In their order of use these are:
- confirm:: Adds confirmation dialog. -condition:: Perform remote request conditionally by this expression. Use this to describe browser-side conditions when request should not be initiated.
- before:: Called before request is initiated.
- after:: Called immediately after request was initiated and before loading.
- Parameters:
-
string $title Title of link string $href Href string "/products/view/12" array $options Options for JavaScript function string $confirm Confirmation message. Calls up a JavaScript confirm() message. boolean $escapeTitle Escaping the title string to HTML entities
- Returns:
- string HTML code for link to remote action
Definition at line 177 of file ajax.php.
References remoteFunction(), and Helper::url().
| AjaxHelper::observeField | ( | $ | field, | |
| $ | options = array() | |||
| ) |
Observe field and call ajax on change.
Observes the field with the DOM ID specified by field and makes an Ajax when its contents have changed.
Required +options+ are:
- frequency:: The frequency (in seconds) at which changes to this field will be detected.
- url:: Additional options are:
- update:: Specifies the DOM ID of the element whose innerHTML should be updated with the XMLHttpRequest response text.
- with:: A Javascript expression specifying the parameters for the XMLHttpRequest. This defaults to Form.Element.serialize('$field'), which can be accessed from params['form']['field_id'].
Additionally, you may specify any of the options documented in
- See also:
- linkToRemote().
- Parameters:
-
string $field DOM ID of field to observe array $options ajax options
- Returns:
- string ajax script
Definition at line 353 of file ajax.php.
References _buildObserver().
| AjaxHelper::observeForm | ( | $ | form, | |
| $ | options = array() | |||
| ) |
Observe entire form and call ajax on change.
Like
- See also:
- observeField(), but operates on an entire form identified by the DOM ID form. options are the same as observeField, except the default value of the with option evaluates to the serialized (request string) value of the form.
- Parameters:
-
string $form DOM ID of form to observe array $options ajax options
- Returns:
- string ajax script
Definition at line 375 of file ajax.php.
References _buildObserver().
| AjaxHelper::remoteFunction | ( | $ | options | ) |
Creates JavaScript function for remote AJAX call
This function creates the javascript needed to make a remote call it is primarily used as a helper for AjaxHelper::link.
- Parameters:
-
array $options options for javascript
- Returns:
- string html code for link to remote action
- See also:
- AjaxHelper::link() for docs on options parameter.
Definition at line 215 of file ajax.php.
References Helper::url().
Referenced by _buildObserver(), dropRemote(), form(), link(), remoteTimer(), sortable(), and submit().
| AjaxHelper::remoteTimer | ( | $ | options = null |
) |
Periodically call remote url via AJAX.
Periodically calls the specified url (options[url]) every options[frequency] seconds (default is 10). Usually used to update a specified div (options[update]) with the results of the remote call. The options for specifying the target with url and defining callbacks is the same as linkToRemote.
- Parameters:
-
array $options Callback options
- Returns:
- string Javascript code
Definition at line 262 of file ajax.php.
References remoteFunction().
| AjaxHelper::slider | ( | $ | id, | |
| $ | trackId, | |||
| $ | options = array() | |||
| ) |
Makes a slider control.
- Parameters:
-
string $id DOM ID of slider handle string $trackId DOM ID of slider track array $options Array of options to control the slider http://wiki.script.aculo.us/scriptaculous/show/Slider
Definition at line 551 of file ajax.php.
References $callbacks, _buildOptions(), _optionsToString(), and Helper::value().
| AjaxHelper::sortable | ( | $ | id, | |
| $ | options = array() | |||
| ) |
Makes a list or group of floated objects sortable.
- Parameters:
-
string $id DOM ID of parent array $options Array of options to control sort.http://wiki.script.aculo.us/scriptaculous/show/Sortable.create http://wiki.script.aculo.us/scriptaculous/show/Sortable.create
Definition at line 621 of file ajax.php.
References _buildCallbacks(), _buildOptions(), _optionsToString(), Inflector::camelize(), form(), ife(), remoteFunction(), and Helper::url().
| AjaxHelper::submit | ( | $ | title = 'Submit', |
|
| $ | options = array() | |||
| ) |
Returns a button input tag that will submit using Ajax
Returns a button input tag that will submit form using XMLHttpRequest in the background instead of regular reloading POST arrangement. options argument is the same as in form_remote_tag
- Parameters:
-
string $title Input button title array $options Callback options
- Returns:
- string Ajaxed input button
Definition at line 310 of file ajax.php.
References remoteFunction(), and Helper::value().
Referenced by form().
Member Data Documentation
| AjaxHelper::$ajaxOptions = array('after', 'asynchronous', 'before', 'confirm', 'condition', 'contentType', 'encoding', 'evalScripts', 'failure', 'fallback', 'form', 'indicator', 'insertion', 'interactive', 'loaded', 'loading', 'method', 'onCreate', 'onComplete', 'onException', 'onFailure', 'onInteractive', 'onLoaded', 'onLoading', 'onSuccess', 'onUninitialized', 'parameters', 'position', 'postBody', 'requestHeaders', 'success', 'type', 'update', 'with') |
| AjaxHelper::$autoCompleteOptions = array('afterUpdateElement', 'callback', 'frequency', 'indicator', 'minChars', 'onShow', 'onHide', 'parameters', 'paramName', 'tokens', 'updateElement') |
| AjaxHelper::$callbacks = array('complete', 'create', 'exception', 'failure', 'interactive', 'loading', 'loaded', 'success', 'uninitialized') |
| AjaxHelper::$dragOptions = array('handle', 'revert', 'snap', 'zindex', 'constraint', 'change', 'ghosting', 'starteffect', 'reverteffect', 'endeffect') |
| AjaxHelper::$dropOptions = array('accept', 'containment', 'greedy', 'hoverclass', 'onHover', 'onDrop', 'overlap') |
| AjaxHelper::$editorOptions = array('okText', 'cancelText', 'savingText', 'formId', 'externalControl', 'rows', 'cols', 'size', 'highlightcolor', 'highlightendcolor', 'savingClassName', 'formClassName', 'loadTextURL', 'loadingText', 'callback', 'ajaxOptions', 'clickToEditText', 'collection', 'okButton', 'cancelLink') |
| AjaxHelper::$helpers = array('Html', 'Javascript', 'Form') |
| AjaxHelper::$sliderOptions = array('alignX', 'alignY', 'axis', 'disabled', 'handleDisabled', 'handleImage', 'increment', 'maximum', 'minimum', 'onChange', 'onSlide', 'range', 'sliderValue', 'values') |
| AjaxHelper::$sortOptions = array('constraint', 'containment', 'dropOnEmpty', 'ghosting', 'handle', 'hoverclass', 'onUpdate', 'onChange', 'only', 'overlap', 'scroll', 'scrollSensitivity', 'scrollSpeed', 'tag', 'tree', 'treeTag', 'update') |
The documentation for this class was generated from the following file:
- 1.2.x.x/cake/libs/view/helpers/ajax.php