AjaxHelper Class Reference

Inheritance diagram for AjaxHelper:

AppHelper Helper Helper Overloadable Overloadable Object Object Object Object List of all members.

Public Member Functions

 __getHtmlOptions ($options, $extra=array())
 __optionsForAjax ($options)
 _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

 $__ajaxBuffer = array()
 $ajaxOptions
 $autoCompleteOptions
 $callbacks
 $dragOptions
 $dropOptions
 $editorOptions
 $helpers = array('Html', 'Javascript', 'Form')
 $Html = null
 $Javascript = null
 $sliderOptions
 $sortOptions

Detailed Description

Definition at line 35 of file ajax.php.


Member Function Documentation

AjaxHelper::__getHtmlOptions ( options,
extra = array() 
)

Private Method to return a string of html options option data as a JavaScript options hash.

Parameters:
array $options Options in the shape of keys and values
array $extra Array of legal keys in this options context
Returns:
array Array of html options private

Definition at line 817 of file ajax.php.

Referenced by autoComplete(), form(), link(), and submit().

AjaxHelper::__optionsForAjax ( options  ) 

Private helper function for Javascript.

Parameters:
array $options Set of options private

Definition at line 741 of file ajax.php.

References _buildCallbacks(), _buildOptions(), _optionsToString(), camelize(), and form().

Referenced by editor(), and remoteFunction().

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 882 of file ajax.php.

References $callbacks.

Referenced by __optionsForAjax(), and 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 864 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 832 of file ajax.php.

References $out.

Referenced by __optionsForAjax(), 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 927 of file ajax.php.

Referenced by __optionsForAjax(), 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 952 of file ajax.php.

References Helper::$data, $out, Object::_stop(), 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 additional fields.

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 450 of file ajax.php.

References $url, __getHtmlOptions(), _buildOptions(), _optionsToString(), and 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 503 of file ajax.php.

References $id, 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 523 of file ajax.php.

References $id, 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://github.com/madrobby/scriptaculous/wikis/draggable

Parameters:
unknown_type $id
array $options
Returns:
unknown

Definition at line 551 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://github.com/madrobby/scriptaculous/wikis/droppables

Parameters:
unknown_type $id
array $options
Returns:
string

Definition at line 570 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 594 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://github.com/madrobby/scriptaculous/wikis/ajax-inplaceeditor

Definition at line 656 of file ajax.php.

References $url, __optionsForAjax(), _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 AjaxHelper::link().

Parameters:
mixed $params Either a string identifying the form target, or an array of method parameters, including:
  • 'params' => Acts as the form target
  • 'type' => 'post' or 'get'
  • 'options' => An array containing all HTML and script options used to generate the form tag and Ajax request.
array $type How form data is posted: 'get' or 'post'
array $options Callback/HTML options
Returns:
string JavaScript/HTML code
See also:
AjaxHelper::link()

Definition at line 317 of file ajax.php.

References Helper::$params, __getHtmlOptions(), Helper::model(), remoteFunction(), submit(), and Helper::url().

Referenced by __optionsForAjax(), and editor().

AjaxHelper::isAjax (  ) 

Detects Ajax requests

Returns:
boolean True if the current request is a Prototype Ajax update call

Definition at line 540 of file ajax.php.

References params().

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:

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:

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 203 of file ajax.php.

References __getHtmlOptions(), 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:

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 401 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 425 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 243 of file ajax.php.

References __optionsForAjax(), and 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 AjaxHelper::link().

Parameters:
array $options Callback options
Returns:
string Javascript code
See also:
AjaxHelper::link()

Definition at line 292 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://github.com/madrobby/scriptaculous/wikis/slider

Definition at line 619 of file ajax.php.

References $callbacks, $id, _buildOptions(), and _optionsToString().

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://github.com/madrobby/scriptaculous/wikis/sortable

Definition at line 698 of file ajax.php.

References _buildCallbacks(), _buildOptions(), _optionsToString(), 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 AjaxHelper::form().

Parameters:
string $title Input button title
array $options Callback options
Returns:
string Ajaxed input button
See also:
AjaxHelper::form()

Definition at line 355 of file ajax.php.

References __getHtmlOptions(), remoteFunction(), and Helper::value().

Referenced by form().


Member Data Documentation

AjaxHelper::$__ajaxBuffer = array()

Definition at line 139 of file ajax.php.

AjaxHelper::$ajaxOptions

Initial value:

 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'
    )

Definition at line 70 of file ajax.php.

Referenced by dropRemote().

AjaxHelper::$autoCompleteOptions

Initial value:

 array(
        'afterUpdateElement', 'callback', 'frequency', 'indicator', 'minChars', 'onShow', 'onHide',
        'parameters', 'paramName', 'tokens', 'updateElement'
    )

Definition at line 130 of file ajax.php.

AjaxHelper::$callbacks

Initial value:

 array(
        'complete', 'create', 'exception', 'failure', 'interactive', 'loading',
        'loaded', 'success', 'uninitialized'
    )

Definition at line 61 of file ajax.php.

Referenced by _buildCallbacks(), and slider().

AjaxHelper::$dragOptions

Initial value:

 array(
        'handle', 'revert', 'snap', 'zindex', 'constraint', 'change', 'ghosting',
        'starteffect', 'reverteffect', 'endeffect', 'scroll', 'scrollSensitivity',
        'onStart', 'onDrag', 'onEnd'
    )

Definition at line 82 of file ajax.php.

AjaxHelper::$dropOptions

Initial value:

 array(
        'accept', 'containment', 'greedy', 'hoverclass', 'onHover', 'onDrop', 'overlap'
    )

Definition at line 92 of file ajax.php.

AjaxHelper::$editorOptions

Initial value:

 array(
        'okText', 'cancelText', 'savingText', 'formId', 'externalControl', 'rows', 'cols', 'size',
        'highlightcolor', 'highlightendcolor', 'savingClassName', 'formClassName', 'loadTextURL',
        'loadingText', 'callback', 'ajaxOptions', 'clickToEditText', 'collection', 'okControl',
        'cancelControl', 'submitOnBlur'
    )

Definition at line 119 of file ajax.php.

AjaxHelper::$helpers = array('Html', 'Javascript', 'Form')

Reimplemented from Helper.

Definition at line 41 of file ajax.php.

AjaxHelper::$Html = null

Definition at line 48 of file ajax.php.

AjaxHelper::$Javascript = null

Definition at line 55 of file ajax.php.

AjaxHelper::$sliderOptions

Initial value:

 array(
        'alignX', 'alignY', 'axis', 'disabled', 'handleDisabled', 'handleImage', 'increment',
        'maximum', 'minimum', 'onChange', 'onSlide', 'range', 'sliderValue', 'values'
    )

Definition at line 110 of file ajax.php.

AjaxHelper::$sortOptions

Initial value:

 array(
        'constraint', 'containment', 'dropOnEmpty', 'ghosting', 'handle', 'hoverclass', 'onUpdate',
        'onChange', 'only', 'overlap', 'scroll', 'scrollSensitivity', 'scrollSpeed', 'tag', 'tree',
        'treeTag', 'update'
    )

Definition at line 100 of file ajax.php.


The documentation for this class was generated from the following file:
Generated on Sun Nov 22 00:30:55 2009 for CakePHP 1.2.x.x (v1.2.4.8284) by doxygen 1.4.7