API16

JHtmlGrid/behavior: Difference between revisions

From Joomla! Documentation

m clean up
m preparing for archive only
 
Line 61: Line 61:


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=behavior
  category=behavior
  category=JHtmlGrid
  category=JHtmlGrid
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*

Latest revision as of 01:45, 25 March 2017

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

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


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

Examples

Code Examples