AJAX
[ class tree: AJAX ] [ index: AJAX ] [ all elements ]

Class: HTML_AJAX_Action

Source Location: /HTML_AJAX-0.5.6/AJAX/Action.php

Class Overview

HTML_AJAX_Response
   |
   --HTML_AJAX_Action

Helper class to eliminate the need to write javascript functions to deal with data


Author(s):

Version:

  • Release: 0.5.6

Copyright:

  • 2005-2008 Elizabeth Smith

Variables

Methods


Inherited Variables

Inherited Methods

Class: HTML_AJAX_Response

HTML_AJAX_Response::getContentType()
Returns the appropriate content type
HTML_AJAX_Response::getPayload()
Returns the serialized content of the response class

Class Details

[line 38]
Helper class to eliminate the need to write javascript functions to deal with data

This class creates information that can be properly serialized and used by the haaction serializer which eliminates the need for php users to write javascript for dealing with the information returned by an ajax method - instead the javascript is basically created for them



[ Top ]


Class Variables

$contentType =  'application/html_ajax_action'

[line 50]

Content type for the HAA response

goofy but unique content type to tell the javascript which deserializer to use overrides HTML_AJAX_Response

  • Access: public

Type:   string
Overrides:   Array


[ Top ]



Method Detail

appendAttr   [line 109]

void appendAttr( string $id, string|array $attribute, [mixed $data = null])

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

  • Access: public

Parameters:

string   $id     id for a specific item on the page <div id="myid"></div>
string|array   $attribute     either an array of attribute/data pairs or a string attribute name
mixed   $data     should be NULL if attribute is an array, otherwise data you wish to set the attribute to

[ Top ]

assignAttr   [line 138]

void assignAttr( string $id, string|array $attribute, [mixed $data = null])

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

  • Access: public

Parameters:

string   $id     id for a specific item on the page <div id="myid"></div>
string|array   $attribute     either an array of attribute/data pairs or a string attribute name
mixed   $data     should be NULL if attribute is an array, otherwise data you wish to set the attribute to

[ Top ]

clearAttr   [line 165]

void clearAttr( string $id, string|array $attribute)

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

  • Access: public

Parameters:

string   $id     id for a specific item on the page <div id="myid"></div>
string|array   $attribute     either an array of attribute/data pairs or a string attribute name

[ Top ]

combineActions   [line 340]

array combineActions( object &$instance)

Adds all the actions from one response object to another, feature request #6635 at pear.php.net
  • Access: public

Parameters:

object   &$instance     referenced HTML_AJAX_Action object

[ Top ]

createNode   [line 210]

void createNode( string $id, string $tag, array $attributes, [string $type = 'append'])

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.

  • Access: public

Parameters:

string   $id     id for a specific item on the page <div id="myid"></div>
string   $tag     html node to create
array   $attributes     array of attribute -> data to fill the node with
string   $type     append|prepend|insertBefore|insertAfter default is append

[ Top ]

getPayload   [line 325]

string getPayload( )

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: serialized response content
  • Access: public

Overrides HTML_AJAX_Response::getPayload() (Returns the serialized content of the response class)
[ Top ]

insertAlert   [line 307]

void insertAlert( string $data)

Send a string to a javascript alert

This will send the data right to the alert javascript function

  • Access: public

Parameters:

string   $data     string to pass to the alert javascript function

[ Top ]

insertScript   [line 288]

void insertScript( string $data)

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

  • Access: public

Parameters:

string   $data     string to pass to the alert javascript function

[ Top ]

prependAttr   [line 79]

void prependAttr( string $id, string|array $attribute, [mixed $data = null])

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

  • Access: public

Parameters:

string   $id     id for a specific item on the page <div id="myid"></div>
string|array   $attribute     either an array of attribute/data pairs or a string attribute name
mixed   $data     should be NULL if attribute is an array, otherwise data you wish to set the attribute to

[ Top ]

removeNode   [line 267]

void removeNode( string $id)

Delete a dom node via javascript

$response->removeNode('myid'); $response->removeNode(array('mydiv', 'myform'));

  • Access: public

Parameters:

string   $id     id for a specific item on the page <div id="myid"></div>

[ Top ]

replaceNode   [line 244]

void replaceNode( string $id, string $tag, array $attributes)

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

  • Access: public

Parameters:

string   $id     id for a specific item on the page <div id="myid"></div>
string   $tag     html node to create
array   $attributes     array of attribute -> data to fill the node with

[ Top ]

retrieveActions   [line 352]

array retrieveActions( )

to follow proper property access we need a way to retrieve the private actions array
  • Access: public

[ Top ]


Documentation generated on Mon, 16 Jun 2008 15:00:06 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.