| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Source view] [Print] [Project Stats]
OO AJAX Implementation for PHP, contains HTML_AJAX_Action SVN Rev: $Id: Action.php,v 1.1.2.1 2008/10/03 07:09:50 nicolasconnault Exp $
| Author: | Elizabeth Smith <auroraeosrose@gmail.com> |
| Copyright: | 2005-2008 Elizabeth Smith |
| License: | http://www.opensource.org/licenses/lgpl-license.php LGPL |
| Version: | Release: 0.5.6 |
| File Size: | 357 lines (11 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
HTML_AJAX_Action:: (12 methods):
prependAttr()
appendAttr()
assignAttr()
clearAttr()
createNode()
replaceNode()
removeNode()
insertScript()
insertAlert()
getPayload()
combineActions()
retrieveActions()
Class: HTML_AJAX_Action - X-Ref
Helper class to eliminate the need to write javascript functions to deal with data| prependAttr($id, $attribute, $data = null) X-Ref |
| Prepends data to the attribute identified by id The data will be added to the beginning of the attribute identified by the id sent, id must be unique $response->prependAttr('myid', 'class', 'red'); $response->prependAttr('myid', array('class' => 'red', 'innerHTML' => 'this is an error')); param: string $id id for a specific item on the page <div id="myid"></div> param: string|array $attribute either an array of attribute/data pairs or a string attribute name param: mixed $data should be NULL if attribute is an array, otherwise data you wish to set the attribute to return: void |
| appendAttr($id, $attribute, $data = null) X-Ref |
| Appends data to the attribute identified by id The data will be added to the end of the attribute identified by the id sent, id must be unique $response->appendAttr('myid', 'class', 'red'); $response->appendAttr('myid', array('class' => 'red', 'innerHTML' => 'this is an error')); param: string $id id for a specific item on the page <div id="myid"></div> param: string|array $attribute either an array of attribute/data pairs or a string attribute name param: mixed $data should be NULL if attribute is an array, otherwise data you wish to set the attribute to return: void |
| assignAttr($id, $attribute, $data = null) X-Ref |
| Assigns data to the attribute identified by id overwriting any previous values The data will be assigned to the attribute identified by the id sent, id must be unique $response->assignAttr('myid', 'class', 'red'); $response->assignAttr('myid', array('class' => 'red', 'innerHTML' => 'this is an error')); param: string $id id for a specific item on the page <div id="myid"></div> param: string|array $attribute either an array of attribute/data pairs or a string attribute name param: mixed $data should be NULL if attribute is an array, otherwise data you wish to set the attribute to return: void |
| clearAttr($id, $attribute) X-Ref |
| Deletes or assigns a value of an empty string to an attribute You may send either a single attribute or an array of attributes to clear $response->clearAttr('myid', 'class'); $response->clearAttr('myid', array('class', 'innerHTML')); param: string $id id for a specific item on the page <div id="myid"></div> param: string|array $attribute either an array of attribute/data pairs or a string attribute name return: void |
| createNode($id, $tag, $attributes, $type = 'append') X-Ref |
| create a dom node via javascript higher level dom manipulation - creates a new node to insert into the dom You can control where the new node is inserted with two things, the insertion type and the id/ The type should be append, prepend, insertBefore, or insertAfter The id is a sibling node - like a div in the same div you want to add more to If you choose to append or prepend a node it will be placed at the beginning or end of the node with the id you send. If you choose insertBefore or InsertAfter it will be put right before or right after the node you specified. You can send an array of attributes to apply to the new node as well, so you don't have to create it and then assign Attributes. <code> $response->createNode('myid', 'div'); $response->createNode('submit', 'input', array('id' => 'key', 'name' => 'key', 'type' => 'hidden', 'value' => $id), 'insertBefore'); <code> param: string $id id for a specific item on the page <div id="myid"></div> param: string $tag html node to create param: array $attributes array of attribute -> data to fill the node with param: string $type append|prepend|insertBefore|insertAfter default is append return: void |
| replaceNode($id, $tag, $attributes) X-Ref |
| Replace a dom node via javascript higher level dom manipulation - replaces one node with another This can be used to replace a div with a form for inline editing use innerHtml attribute to change inside text $response->replaceNode('myid', 'div', array('innerHTML' => 'loading complete')); $response->replaceNode('mydiv', 'form', array('innerHTML' => $form)); param: string $id id for a specific item on the page <div id="myid"></div> param: string $tag html node to create param: array $attributes array of attribute -> data to fill the node with return: void |
| removeNode($id) X-Ref |
| Delete a dom node via javascript $response->removeNode('myid'); $response->removeNode(array('mydiv', 'myform')); param: string $id id for a specific item on the page <div id="myid"></div> return: void |
| insertScript($data) X-Ref |
| Send a string to a javascript eval This will send the data right to the eval javascript function, it will NOT allow you to dynamically add a javascript function for use later on because it is constrined by the eval function param: string $data string to pass to the alert javascript function return: void |
| insertAlert($data) X-Ref |
| Send a string to a javascript alert This will send the data right to the alert javascript function param: string $data string to pass to the alert javascript function return: void |
| getPayload() X-Ref |
| Returns the serialized content of the response class we actually use the json serializer underneath, so we send the actions array to the json serializer and return the data return: string serialized response content |
| combineActions(&$instance) X-Ref |
| Adds all the actions from one response object to another, feature request #6635 at pear.php.net param: object &$instance referenced HTML_AJAX_Action object return: array |
| retrieveActions() X-Ref |
| to follow proper property access we need a way to retrieve the private actions array return: array |
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |