Agile Toolkit  4.2
Agile Toolkit is a powerful web development framework. Inspired by GUI Applications development
AbstractView Class Reference
Inheritance diagram for AbstractView:
AbstractObject ApiCLI Form_Field HelloWorld Html LoremIpsum Menu_Compat Menu_Light MenuItem MenuSeparator Page Paginator_Compat Text View

Public Member Functions

 __clone ()
 getModel ()
 setModel ($model, $actual_fields=undefined)
 _tsBuffer ($t, $data)
 getHTML ($destroy=true, $execute_js=true)
 initializeTemplate ($template_spot=null, $template_branch=null)
 initTemplateTags ()
 defaultTemplate ()
 defaultSpot ()
 recursiveRender ()
 moveJStoParent ()
 render ()
 output ($txt)
 region_render ()
 object_render ()
 js ($when=null, $code=null, $instance=null)

Data Fields

 $template = false
 $template_flush = false
 $default_controller = null
 $auto_track_element = true
 $_tsBuffer = ''
 $js = array()

Detailed Description

A base class for all Visual objects in Agile Toolkit. The important distinctive property of all Views is abiltiy to render themselves (produce HTML) automatically and recursively.

Member Function Documentation

__clone ( )

Duplicate view and it's template. Will not duplicate children

Reimplemented from AbstractObject.

_tsBuffer ( t,

Default tag in parent's template where output is inserted, when 3rd argument of add() is omitted

Reimplemented in Paginator_Basic.

getHTML ( destroy = true,
execute_js = true 

Converting View into string will render recursively and produce HTML. If argument is passed, JavaScript will be added into on_ready section of your document like when rendered normally. Note that you might require to destroy object if you don't want it's HTML to appear normally

getModel ( )

Get associated model. It's safe to access $object->model directly.

Reimplemented from AbstractObject.

initializeTemplate ( template_spot = null,
template_branch = null 

Reimplemented in Form_Basic.

js ( when = null,
code = null,
instance = null 

Function js() will return jQuery chain and, if first argument was specified, bind the chain to a certain enent. Use js() to bind views with JavaScript plugins and calls defined in univ() chain or in 3rd party plugins.

js([action], [other_chain]);

Action can represent javascript event, such as "click" or "mouseenter". If you specify action = true, then the event will ALWAYS be executed on pageload. It will also be executed if respective view is being reloaded by js()->reload() (Do not make mistake by specifying "true" instead of true)

action = false will still return jQuery chain but will not bidn it. You can bind it by passing to a different object's js() call as 2nd argument or by executing chain.

1. Calling with arguments:

$view->js(); // does nothing $a = $view->js()->hide(); // creates chain for hiding $view but does not // bind to event yet.

2. Binding existing chains $img->js('mouseenter', $a); // binds previously defined chain to event on // event of $img.

Produced code: $('#img_id').click(function(ev){ ev.preventDefault(); $('view1').hide(); });

3. $button->js('click',$form->js()->submit()); // clicking button will result in form submit

4. $view->js(true)->find('.current')->text($text);

Will convert calls to jQuery chain into JavaScript string: $('#view').find('.current').text('abc'); // The $text will be json-encoded // to avoid JS injection.



Will inject javascript un-escaped portion of javascript into chain. If you need to have a custom script then put it into file instead, save into templates/js/myfile.js and then include:


It's highly suggested to bind your libraries with jQuery namespace by registered them as plugins, this way you can call your function easily:


When cutting, perform selective render for an object

if GET['cut'] is set, then only particular object will be rendered

output ( txt)

Low level output function which append's to the parent object's template. Normally you wouldn't want to use this function but should modify $this->template instead.

Recursively renders all views. Calls render() for all or for the one being cut. In some cases you may want to redefine this function instead of render(). The difference is that this function is called before sub-views are rendered, but render() is called after.

function recursiveRender(){ $this->add('Text')->set('test'); return parent::recursiveRender(); }

Reimplemented in View_Columns, and HX.

When cutting, perform selective render for a region

if GET['ajax'] is set, we need only one chunk of a page

render ( )

Default render. Generates HTML presentation of the view based on $this->template and passes it to output() function which then inserts output into parent's template

For visual objects, their default action while rendering is rely on SMlite engine. For sake of simplicity and speed you can redefine this method with a simple call

Reimplemented in Form_Field_Hidden, Form_Basic, ApiWeb, Form_Field, Grid_Advanced, Lister, CompleteLister, MenuItem, Paginator_Compat, LoremIpsum, Menu_Basic, View_Button, Menu_Light, Text, View_Icon, View_Box, InfoWindow, View_ButtonSet, HelloWorld, Frame, and Html.

setModel ( model,
actual_fields = undefined 

Associate view with a model. Different models may behave differently.

Field Documentation

$_tsBuffer = ''
$auto_track_element = true

When this object is added, owner->elements[$this->short_name] will be == $this;

Reimplemented from AbstractObject.

$default_controller = null

When using setModel() with Views some views will want to populate fields, columns etc corresponding to models meta-data. That is the job of Controller. When you create a custom controller for your view set this property to point at your controller and it will be used automatically

Reimplemented from AbstractObject.

Reimplemented in Grid_Advanced, Form_Basic, and Grid_Basic.

$js = array()

$spot defines a place on a parent's template where render() will output() resulting HTML

See also:
$template = false

$template is an SMLite object containing indexed HTML template.


$view->template->set('title', $my_title);

Assuming you have tag <?$template?> in template file associated with this view - will insert text into this tag.

See also:
$template_flush = false

The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables Enumerations