protected function addDeferredJavaScript(WidgetAssetInterface $widget, Response $response)
    {
        if ($this->deferAdded) {
            return;
        }

        $javaScript = $this->render->render(
            'widgetjavascript.twig',
            [
                'widget' => $widget,
            ]
        );
        $snippet = (new Snippet())
            ->setLocation(Target::AFTER_BODY_JS)
            ->setCallback((string) $javaScript)
        ;

        $this->deferAdded = true;

        $this->injector->inject($snippet, Target::AFTER_BODY_JS, $response);
    }
protected function addDeferredJavaScript(WidgetAssetInterface $widget, Response $response)
    {
        if ($this->deferAdded) {
            return;
        }

        $javaScript = $this->render->render(
            'widgetjavascript.twig',
            [
                'widget' => $widget,
            ]
        );
        $snippet = (new Snippet())
            ->setLocation(Target::AFTER_BODY_JS)
            ->setCallback((string) $javaScript)
        ;

        $this->deferAdded = true;

        $this->injector->inject($snippet, Target::AFTER_BODY_JS, $response);
    }
protected function addDeferredJavaScript ( WidgetAssetInterface $ widget , Response $ response ) { if ( $ this -> deferAdded ) { return ; } $ javaScript = $ this -> render -> render ( 'widgetjavascript.twig' , [ 'widget' => $ widget , ] ) ; $ snippet = ( new Snippet ( ) ) -> setLocation ( Target :: AFTER_BODY_JS ) -> setCallback ( ( string ) $ javaScript ) ; $ this -> deferAdded = true ; $ this -> injector -> inject ( $ snippet , Target :: AFTER_BODY_JS , $ response ) ; }
Insert a snippet of Javascript to fetch the actual widget's contents.

@param WidgetAssetInterface $widget
@param Response             $response
Insert a snippet of Javascript to fetch the actual widget s contents .