Answer the question
In order to leave comments, you need to log in
Yii2 How to implement a redirect to the same page and to the RIGHT place of the user?
I return the user to the same page
like this
return $this->redirect(Yii::$app->request->referrer);
Answer the question
In order to leave comments, you need to log in
Without JS, this will not work, because for the browser it is not similar to the "back" button, but a full-fledged new page. That is, you have to somehow remember and transmit the user's location. It will be easier to make your call ajax so that the page does not reload at all.
In the URI string, pass #element_id at the end, provided that there is, for example, a div with id = "element_id" will transfer you to it.
If you send the position of the top of the page from the top of the document before the update, then you can pass this value to get and rewind the page using javascript to this value
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question