API16

JHtmlGrid/behavior

From Joomla! Documentation

< API16:JHtmlGrid

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

<! removed transcluded page call, red link never existed >

Syntax[edit]

static behavior()


Defined in[edit]

libraries/joomla/html/html/grid.php

Importing[edit]

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

Source Body[edit]

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


<! removed transcluded page call, red link never existed >

Examples[edit]

Code Examples[edit]