L
L
LightSid2016-10-27 14:49:10
Yii
LightSid, 2016-10-27 14:49:10

How to reload page actionIndex from Yii2 widget?

Can you please tell me how to reload the main page from the body of the widget?
return $this->refresh(); does not work, as I understand it, it reloads the widget code, but the whole page is needed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-10-27
@LightSid

1. The main question is why? This is not right. Describe the complete task, maybe there is another way out.
2. If we look at the refresh controller method, we will see:

public function refresh($anchor = '')
    {
        return Yii::$app->getResponse()->redirect(Yii::$app->getRequest()->getUrl() . $anchor);
    }

This means that refresh() is not so necessary, which is not available from the widget.
Off topic, but for future reference:
$this in a widget is a widget instance
$this->getView() in a widget is a View instance
$this->getView()->context some data from the controller, like public variables

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question