Adds an event handler on an element
$response->addEvent('my_button', 'click', "alert('Hello World!');");
void
addEvent
(string $id, string $type, string $func, [bool $capture = TRUE])
-
string
$id: Element ID
-
string
$type: Event type
-
string
$func: Function
-
bool
$capture: Capture flag
Shows an alert message
void
alert
(string $msg)
Calls a JS function
$response->callFunction('myFunction', array(1, 'str', true), 'myObject');
void
callFunction
(string $func, [array $params = array()], [string $scope = NULL], [int $delay = 0])
-
string
$func: Function ID
-
array
$params: Function params
-
string
$scope: Function scope
-
int
$delay: Delay, in miliseconds
Clears one or more fields
$response->clear(array('product_id', 'amount'));
void
clear
(string $id)
-
string
$id: Field ID or IDs
Clears a given field given its name and form ID
void
clearByName
(string $formId, string $fieldName)
-
string
$formId: Form ID
-
string
$fieldName: Field name
Clear the contents of an element
void
clearContents
(string $id)
Shows a confirmation message
Set skip to 0 to skip all next commands if the user chooses 'no'.
// skip only next command
$response->confirm("Are u sure?", 1);
// skip all following commands
$response->confirm("Click OK to proceed", 0);
void
confirm
(string $msg, [int $skip = 1])
-
string
$msg: Message
-
int
$skip: Number of commands to skip if user chooses 'no'
Creates a new element in the DOM tree
$response->create('input', array('name' =>
'text_box', 'type'=>
'text'), NULL, 'my_form');
void
create
(string $tag, [array $attrs = array()], [array $contents = NULL], [string $parent = NULL])
-
string
$tag: Tag name
-
array
$attrs: Element attributes
-
array
$contents: Element contents
-
string
$parent: Parent node
Disables one or more form fields
void
disable
(string|array $id)
-
string|array
$id: Field ID or IDs
Disables a field given its name and form ID
void
disableByName
(string $formId, string $fieldName)
-
string
$formId: Form ID
-
string
$fieldName: Field name
Enables one or more form fields
$response->enable('order_type');
$response->enable(array('phone', 'cellphone'));
void
enable
(string|array $id)
-
string|array
$id: Field ID or IDs
Enables a field given its name and form ID
void
enableByName
(string $formId, string $fieldName)
-
string
$formId: Form ID
-
string
$fieldName: Field name
Populates a combo box with a given set of options
'M' => 'Male',
'F' => 'Female'
), true, 'M');
void
fillCombo
(string $id, array $options, [bool $clear = TRUE], [mixed $value = NULL])
-
string
$id: Combo ID
-
array
$options: Combo options
-
bool
$clear: If existent options must be removed
-
mixed
$value: Combo value
Give focus to a given field
$response->focus('client_name');
void
focus
(string $id)
Give focus to a given field given its name and form ID
$response->focus('hire_form', 'employee_name');
void
focusByName
(string $formId, string $fieldName)
-
string
$formId: Form ID
-
string
$fieldName: Field name
Hides one or more elements
$response->hide('product_details');
$response->hide(array('shopping_cart', 'add_product'));
void
hide
(string|array $id)
-
string|array
$id: Element ID or IDs
Insert content on an element
$response->insertContents('container', "<div>Record saved at " .
date('r') .
"</div>", 'bottom');
void
insertContents
(string $id, string $code, [string $pos = 'bottom'], [bool $evalScripts = FALSE])
-
string
$id: Element ID
-
string
$code: Code
-
string
$pos: Insert position (before, top, after or bottom)
-
bool
$evalScripts: If scripts must be evaluated
Redirects to a given URL
void
redirect
(string $url)
Removes an element from the tree
$response->remove('shopping_cart');
void
remove
(string $id)
Removes an event handler from an element
void
removeEvent
(string $id, string $type, string $func, [bool $capture = TRUE])
-
string
$id: Element ID
-
string
$type: Event type
-
string
$func: Function
-
bool
$capture: Capture flag
Renders all response commands as a JSON string
This method is automatically called by AjaxService class when the response is generated.
void
render
([bool $isIframe = FALSE])
-
bool
$isIframe: Indicate we're responding to an IFRAME
Replace an element of the DOM tree by a given HTML code
void
replaceContents
(string $id, string $code, [bool $evalScripts = FALSE])
-
string
$id: Element ID
-
string
$code: Replace code
-
bool
$evalScripts: If scripts must be evaluated
Reset a form by ID
void
resetForm
(string $id)
Runs a block of JS code
$response->runScript("var div = $('my_div');");
$response->runScript("$('my_element').hide(); $('my_field').addClass('class_name');");
void
runScript
(string $script)
Set one or more attributes of an element
'action' => 'process_hire.php',
'method' => 'post'
));
void
setAttribute
(string $id, string|array $attr, [mixed $value = ''])
-
string
$id: Element ID
-
string|array
$attr: Attribute name or attributes hash
-
mixed
$value: Attribute value
Set response charset
void
setCharset
(string $charset)
Set one or more style properties of an element
$response->setStyle('error_header', 'background-color', 'red');
'opacity' => 0.8,
'border' => '1px solid black'
));
void
setStyle
(string $id, string|array $attr, [mixed $value = ''])
-
string
$id: Element ID
-
string|array
$attr: Attribute name or attributes hash
-
mixed
$value: Attribute value
Defines the value of one or more form fields
'address' => 'Elm Street, 123',
'phone' => '5555-6666'
));
void
setValue
(string $id, [mixed $value = ''])
-
string
$id: Field ID or hash array of fields/values
-
mixed
$value: Field value
Defines the value of a field given its name and the form ID
void
setValueByName
(string $formId, string $fieldName, mixed $value)
-
string
$formId: Form ID
-
string
$fieldName: Field name
-
mixed
$value: Field value
Set a Javascript variable
void
setVariable
(string $name, mixed $value)
-
string
$name: Variable name
-
mixed
$value: Variable value
Shows one or more elements
$response->show(array('error_header', 'error_details'));
$response->show('login_div');
void
show
(string|array $id)
-
string|array
$id: Element ID or IDs
Updates the contents of an element
$response->updateContents('error_div', "Error trying to save record to the database!");
void
updateContents
(string $id, string $code, [bool $evalScripts = FALSE], [bool $useDom = FALSE])
-
string
$id: Element ID
-
string
$code: Code
-
bool
$evalScripts: If scripts must be evaluated
-
bool
$useDom: If DOM must be used to update the contents
Inherited Methods
Inherited From PHP2Go
PHP2Go::PHP2Go()
PHP2Go::equals()
PHP2Go::generateUniqueId()
PHP2Go::getClassName()
PHP2Go::getConfigVal()
PHP2Go::getLangVal()
PHP2Go::getObjectName()
PHP2Go::getParentName()
PHP2Go::hasDestructor()
PHP2Go::hashCode()
PHP2Go::isA()
PHP2Go::isSubclassOf()
PHP2Go::logError()
PHP2Go::raiseError()
PHP2Go::registerDestructor()
PHP2Go::registerShutdownFunc()
PHP2Go::retrieve()
PHP2Go::store()
PHP2Go::__toString()