Inherits Plugin.

Public Member Functions | |
| tpAJAX () | |
| dialog ($dlg_id, $target, $buttons=array(), $overlay=false, $modal=false, $opts=array()) | |
| popup_bind ($div_id, $targets=array(), $buttons=array()) | |
| buttons ($buttons, $context, $retjs=false) | |
| autocomplete ($name, $value_id, $value_name, $search_url, $form_id) | |
| autocomplete_multisel ($name, $values, $search_url, $form_id, $max_sel=0) | |
| _attribs ($attribs) | |
Public Attributes | |
| $guid | |
PRONTO WEB FRAMEWORK Copyright (C) 2006, Judd Vinet
Description: Template plugin for AJAX-y widgets/controls.
Definition at line 10 of file ajax.php.
| tpAJAX::autocomplete | ( | $ | name, | |
| $ | value_id, | |||
| $ | value_name, | |||
| $ | search_url, | |||
| $ | form_id | |||
| ) |
Generate an autocomplete textbox widget for a single selection.
This widget requires an AJAX controller to handle the search requests. The controller should return the results in plain text, with each result on a new line. Separate fields with a pipe (|).
Here's an example of a simple AJAX search controller that does both searches and lookups:
function GET_search() {
$this->set_ajax(true);
if($id = $this->param('id')) {
$user = $this->models->user->get($id);
if($user) echo $user['name']."\n";
} else {
$matches = $this->models->user->search($this->param('q'), $this->param('limit'));
foreach($matches as $id=>$name) echo "$id|$name\n";
}
}
| string | $name Name of the form field (usually type="hidden") that will contain the selections. This field will be generated for you automatically. | |
| string | $value_id The "ID" of the current selection. This is the variable that will populate the value="" field of the hidden form variable. | |
| string | $value_name The display vlue of the current selection. This is the variable that will be shown in the browser. If this is set to TRUE, then the widget will request the value name through the $search_url by passing the "id" query var. | |
| string | $search_url Full URL to the AJAX search URL | |
| string | $form_id DOM ID of the form that contains the selections |
Definition at line 264 of file ajax.php.
References $guid, __(), Plugin_Base::depend(), and html.
Referenced by autocomplete_multisel().
| tpAJAX::autocomplete_multisel | ( | $ | name, | |
| $ | values, | |||
| $ | search_url, | |||
| $ | form_id, | |||
| $ | max_sel = 0 | |||
| ) |
Generate an autocomplete textbox widget and "container" div to hold the multiple selections.
This widget requires an AJAX controller to handle the search requests. The controller should return the results in plain text, with each result on a new line. Separate fields with a pipe (|).
Here's an example of a simple AJAX search controller:
function GET_search() {
$this->set_ajax(true);
$matches = $this->models->user->search($this->param('q'), $this->param('limit'));
foreach($matches as $id=>$name) echo "$id|$name\n";
}
| string | $name Name of the form field (usually type="hidden") that will contain the selections. Don't include the trailing '[]' as it will be appended automatically. | |
| array | $values Currently selected values | |
| string | $search_url Full URL to the AJAX search URL | |
| string | $form_id DOM ID of the form that contains the selections | |
| int | $max_sel The maximum number of selections allowed, or zero for unlimited |
Definition at line 354 of file ajax.php.
References $guid, __(), autocomplete(), and Plugin_Base::depend().
| tpAJAX::buttons | ( | $ | buttons, | |
| $ | context, | |||
| $ | retjs = false | |||
| ) |
Return the HTML/JS to create a series of buttons destined for a popup or a dialog.
Action can be one of the following:
Example:
$ajax->buttons(array(
__('OK') => array('action'=>'submit_form', 'form_id'=>'myform'),
__('Thingy') => array('action'=>'ajax_load', 'url'=>url('/ajax/thingy')),
__('Cancel') => array('action'=>'close')
));
| array | $buttons Button configuration | |
| string | $context Either 'popup' or 'dialog', depending on what the buttons will be used in. | |
| boolean | $retjs Return JavaScript code for event handlers as well. If false, the returned HTML will include JavaScript to install the event handlers. |
Definition at line 170 of file ajax.php.
Referenced by dialog(), and popup_bind().
| tpAJAX::dialog | ( | $ | dlg_id, | |
| $ | target, | |||
| $ | buttons = array(), |
|||
| $ | overlay = false, |
|||
| $ | modal = false, |
|||
| $ | opts = array() | |||
| ) |
Create a modal dialog window and bind it to a trigger element/event.
Example:
<div id="mydlg" title="My Dialog">Hello World!</div> <a href="#" id="clickme">Click Me</a> <?php $ajax->dialog('mydlg', '#clickme') ?>
| string | $dlg_id The DOM ID of the content that will be converted into a dialog window. | |
| mixed | $target The jQuery selector of the DOM element used to trigger the dialog window, or an array of the event and selector, eg, array('click','a.trig'). This field can be blank if you want to handle the event yourself. | |
| boolean | $overlay Grey out the background before showing the new window. | |
| boolean | $modal Make the window modal, so the user can't interface with other parts of the window until the dialog is closed. | |
| array | $opts Additional options to pass to jqModal. Options should be contained in the values only (don't use an associative array) and separated with colons, just as you would build them in Javascript. Options can be found on the jqModal website: http://dev.iceburg.net/jquery/jqModal/ |
| tpAJAX::popup_bind | ( | $ | div_id, | |
| $ | targets = array(), |
|||
| $ | buttons = array() | |||
| ) |
Connect an existing div to one or more targets that, when clicked, will make the div visible. Also include zero or more buttons along the bottom of the popup div.
| $div_id | string The DOM ID of the div element serving as the popup | |
| $targets | array jQuery selector(s) for target elements (eg, "a.new-row" or "#btn") | |
| $buttons | array Button configuration (see tpAJAX::buttons() for example) |
Definition at line 117 of file ajax.php.
References buttons().
| tpAJAX::tpAJAX | ( | ) |
Constructor
Definition at line 17 of file ajax.php.
References Plugin_Base::depend(), and Plugin::Plugin().
| tpAJAX::$guid |
Definition at line 12 of file ajax.php.
Referenced by autocomplete(), and autocomplete_multisel().
1.6.1