yii2


Pushstate in pjax only when redirecting


In one of my pages I have a link that is handled by pjax. Basically the user clicks an item, this item becomes "checked" (and saved in the DB).
I have disabled pushState for these requests, because it makes no sense, user effectively stays in the same page, so it's counter-intuitive to change the url.
However, there is a case when this pjax request results in redirect to login page (when the user is not logged in). And this is when I really need pushState to work, and it doesn't because I disabled it in the first place.
Would it be possible to configure pjax in such a way that normal responses work without pushState, but redirect responses (done with X-Pjax-Url header) do perform pushState?
There's no way to do it using current functionality. I've added two more options to pjax and my PR has been accepted to yii2 branch of pjax. So, without further ado:
https://github.com/yiisoft/jquery-pjax
//pushRedirect - Whether to pushState the URL for redirects. Defaults to false.
//replaceRedirect - Whether to replaceState the URL for redirects. Defaults to true.
// ...
jQuery(document).pjax("#example_selector", {
"push": false,
"replace": false,
"pushRedirect": true,
"replaceRedirect": false
});

Related Links

Cannot update an extension to latest version in yii2
checkboxlist not rendering checkbox checked correctly
Differentiate between Frontend and Backend Logs in DBTarget Yii2
yii2 ActiveData Provider
How to use custom php function to filter in ActiveDataProvider
Yii2 sort object defaultOrder
How to display names instead of id's in GridView Yii2?
yii2 / Migration Not Working
Kartik GridView Yii2 : Toggle data not working in toolbar
yii2 http client request and repsponse
How to insert multiple times the value of an attribute in single table in yii2
yii2 SluggableBehavior is applied to only emty slug field
Yii2: Create path and url for folder inside a module
Disable ActiveForm Clientside Validation on button other than submit Yii2
CRUD view link does not work in Yii2
Yii2 DynamicForm: Demo 3: Nested Dynamic Form with types of rooms

Categories

HOME
ibm-bluemix
ionic-framework
pdf
osgi
tizen
ngrx
setup-deployment
razor
elm
google-project-tango
ckeditor
ios-charts
directx
maude-system
rascal
commonmark
task
decimal
uitypeeditor
foselasticabundle
database-replication
swingx
web-sql
excel-2007
sparse-matrix
apache-commons-io
rst2pdf
replaceall
large-file-upload
instant-messaging
uisplitview
contact-form
uiswipegesturerecognizer
language-concepts
cloud-code
hot-module-replacement
android-fingerprint-api
particles.js
nand2tetris
nxlog
arena-simulation
http-redirect
modelmapper
google-datalayer
xml-documentation
rails-routing
logparser
gabor-filter
snmptrapd
typed-lambda-calculus
windows-mobile-6.5
jspdf-autotable
spring-mongodb
orthogonal
gnome-shell-extensions
abcpdf9
static-ip-address
file-writing
asp.net-4.5
fputcsv
ready-api
dlna
asp.net5
netmq
freedesktop.org
jfugue
wso2cloud
qtableview
prerequisites
simple-framework
coveralls
processmodel
wordpress-theme-customize
google-reader
bundles
prettify
listings
coverflow
mylyn
hungarian-algorithm
random-seed
selected
e4x
pvrtc
google-email-migration
labwindows
twrequest
semantic-diff
subscript
transactionscope
pydot
zpt
deobfuscation
heartbeat
invite
coda-slider
dmx512
dbal
perfect-hash
thunderbird-lightning
libs
ti-dsp
ctp4
procedural-music
ubuntu-9.04

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App