Back to Bootstrap class

Method button

public static void
button
(mixed $selector = '')
Add javascript support for Bootstrap buttons
Parameters
  • string $selector Common class for the buttons
Returns
  • void
Since
  • 3.1
-
  • \Exception
Class: Bootstrap
Project: Joomla

Method button - Source code

/**
 * Add javascript support for Bootstrap buttons
 *
 * @param   string  $selector  Common class for the buttons
 *
 * @return  void
 *
 * @throws \Exception
 *
 * @since   3.1
 */
public static function button($selector = '') : void
{
    // Only load once
    if (!empty(static::$loaded[__METHOD__][$selector])) {
        return;
    }
    $doc = Factory::getDocument();
    if ($selector !== '') {
        $scriptOptions = $doc->getScriptOptions('bootstrap.button');
        $options = [$selector];
        if (is_array($scriptOptions)) {
            $options = array_merge($scriptOptions, $options);
        }
        $doc->addScriptOptions('bootstrap.button', $options, false);
    }
    // Include the Bootstrap component
    Factory::getApplication()->getDocument()->getWebAssetManager()->useScript('bootstrap.button');
    static::$loaded[__METHOD__][$selector] = true;
}