yii-jquery icon indicating copy to clipboard operation
yii-jquery copied to clipboard

Redirect when X-Redirect

Open abdula571 opened this issue 8 years ago • 5 comments

Привет! У меня приложение работает на ajax. И когда я делаю в контроллере $this->redirect(): страница перезагружается.

За это отвечает кусок кода в yii.js

function initRedirectHandler() {
        // handle AJAX redirection
        $(document).ajaxComplete(function (event, xhr) {
            var url = xhr && xhr.getResponseHeader('X-Redirect');
            if (url) {
                window.location.assign(url);
            }
        });
    }

Мне в своей системе нужно другое поведение. И я хотел спросить нельзя сделать это поведение настраиваемым. Например вынести этот кусок

if (url) { window.location.assign(url); }

в callback, и чтобы разработчик мог устанавливать этот callback на свое усмотрение, например в моем случае

window.yii.setRedirectHandler(function(url){ Req.post(url); });

abdula571 avatar Oct 14 '17 18:10 abdula571

Да, приделать callback будет нормально. Сделаете pull request?

samdark avatar Oct 14 '17 19:10 samdark

Попробую. Как рас не было опыта в этом. )

abdula571 avatar Oct 14 '17 19:10 abdula571

Sorry don't get me wrong guys but shouldn't we be talking English here? I'm Romanian and I live in Spain, I know russians don't like Americans but hell let's use a common language for development..

atrandafir avatar Jan 12 '18 19:01 atrandafir

@atrandafir we should, of course. The problem is that sometimes the choice is between either non-communicating or communicating in non-English. Unlike Europe, the percent of English-speaking people in Russia and China is quite low. In these cases I prefer communicating through Google Translate to non-communicating.

samdark avatar Jan 12 '18 23:01 samdark

@abdula571 any progress with a pull request?

samdark avatar Feb 03 '18 12:02 samdark