yii-jquery
yii-jquery copied to clipboard
Redirect when X-Redirect
Привет! У меня приложение работает на 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); });
Да, приделать callback будет нормально. Сделаете pull request?
Попробую. Как рас не было опыта в этом. )
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 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.
@abdula571 any progress with a pull request?