Actions

API16

JHtmlGrid/behavior

From Joomla! Documentation

< API16:JHtmlGrid
Revision as of 17:51, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

[Edit Descripton]

Description:JHtmlGrid/behavior

Contents

Syntax

static behavior()


Defined in

libraries/joomla/html/html/grid.php

Importing

jimport( 'joomla.html.html.grid' );

Source Body

static function behavior()
{
        static $loaded;
 
        if (!$loaded)
        {
                // Build the behavior script.
                $js = '
        window.addEvent(\'domready\', function(){
                actions = $$(\'a.move_up\');
                actions.combine($$(\'a.move_down\'));
                actions.combine($$(\'a.grid_true\'));
                actions.combine($$(\'a.grid_false\'));
                actions.combine($$(\'a.grid_trash\'));
                actions.each(function(a){
                        a.addEvent(\'click\', function(){
                                args = JSON.decode(this.rel);
                                listItemTask(args.id, args.task);
                        });
                });
                $$(\'input.check-all-toggle\').each(function(el){
                        el.addEvent(\'click\', function(){
                                if (el.checked) {
                                        document.id(this.form).getElements(\'input[type=checkbox]\').each(function(i){
                                                i.checked = true;
                                        })
                                }
                                else {
                                        document.id(this.form).getElements(\'input[type=checkbox]\').each(function(i){
                                                i.checked = false;
                                        })
                                }
                        });
                });
        });';
 
                // Add the behavior to the document head.
                $document = & JFactory::getDocument();
                $document->addScriptDeclaration($js);
 
                $loaded = true;
        }
}

[Edit See Also] SeeAlso:JHtmlGrid/behavior

Examples

<CodeExamplesForm />