src/View/Helper/JsHelper.php
public function widget($jSelector, $widgetName, array $params = [], $return = false)
    {
        static $included = [];

        $jSelector = is_array($jSelector) ? implode(', ', $jSelector) : $jSelector;

        $hash = $jSelector . ' /// ' . $widgetName;

        if (!Arr::key($hash, $included)) {
            $included[$hash] = true;
            $widgetName = str_replace('.', '', $widgetName);
            $initScript = '$("' . $jSelector . '").' . $widgetName . '(' . json_encode($params) . ');';

            if ($return) {
                return $this->Html->scriptBlock("\tjQuery(function($){" . $initScript . "});");
            }

            $this->setBuffer($initScript);
        }

        return null;
    }
public function widget($jSelector, $widgetName, array $params = [], $return = false)
    {
        static $included = [];

        $jSelector = is_array($jSelector) ? implode(', ', $jSelector) : $jSelector;

        $hash = $jSelector . ' /// ' . $widgetName;

        if (!Arr::key($hash, $included)) {
            $included[$hash] = true;
            $widgetName = str_replace('.', '', $widgetName);
            $initScript = '$("' . $jSelector . '").' . $widgetName . '(' . json_encode($params) . ');';

            if ($return) {
                return $this->Html->scriptBlock("\tjQuery(function($){" . $initScript . "});");
            }

            $this->setBuffer($initScript);
        }

        return null;
    }
public function widget ( $ jSelector , $ widgetName , array $ params = [ ] , $ return = false ) { static $ included = [ ] ; $ jSelector = is_array ( $ jSelector ) ? implode ( ', ' , $ jSelector ) : $ jSelector ; $ hash = $ jSelector . ' /// ' . $ widgetName ; if ( ! Arr :: key ( $ hash , $ included ) ) { $ included [ $ hash ] = true ; $ widgetName = str_replace ( '.' , '' , $ widgetName ) ; $ initScript = '$("' . $ jSelector . '").' . $ widgetName . '(' . json_encode ( $ params ) . ');' ; if ( $ return ) { return $ this -> Html -> scriptBlock ( "\tjQuery(function($){" . $ initScript . "});" ) ; } $ this -> setBuffer ( $ initScript ) ; } return null ; }
Initialize java script widget.

@param string $jSelector
@param string $widgetName
@param array $params
@param bool $return
@return string|null
Initialize java script widget .