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

How to use models from different domain in frontend's site controller?
frontend login is not working properly in yii2
Yii Gridview show/hide columns from interface when filtering the records
Yii2 skip to other URL route if <controller>/<action> is not found
Include additional library to yii2
Yii2 make session works on all actions of one controller?
Yii2 display data from phpexcel in view before saving to database
yii2 dependant dropdown reset on edit action due to onchange function
Yii2 non-DB (or virtual) attribute isn't populated during massive assignment?
Yii2 Join multiple tables
Codeception Adding custom assert actions (functional testing)
Selected values in yii2
Yii queryBuilder; If dbexpression is not being quoted well
Time attribute validation in Yii2 framework
Yii2 kartik-datecontrol extension
SQL query help in Yii2

Categories

HOME
ionic-framework
hive
vbscript
reflection
tinymce
rdf
icloud
alpha
networkx
virtualization
ibm-odm
telephony
highlight.js
google-static-maps
database-replication
pythonanywhere
openedx
immutable.js
kryo
mustache.php
emgucv
smb
vlsi
tdd
sparse-matrix
virtualdub
tinymce-4
binary-data
iframe-resizer
bosh
typed.js
lxd
automake
gesture
withings
xenforo
bootstrap-dialog
.net-4.6.2
babel-core
google-datalayer
jsch
xml-documentation
upstart
react-scripts
prolog-setof
jquery-validate
typescript1.8
magma
namecoin
capacity
lync-client-sdk
django-scheduler
yt-project
ableton-live
fody
underscore.js-templating
make-install
yaws
itextpdf
uid
feedback
rgeo
nsight
key-management
apache-commons-net
nsmutabledictionary
python-green
formatjs
dd
qpainter
neolane
has-many-through
android-radiobutton
typeof
yorick
android-2.2-froyo
meteor-velocity
mbr
commoncrypto
cdc
file-locking
orchardcms-1.7
interface-orientation
sublist
datawindow
hosts-file
ticoredatasync
chrono
dotnethighcharts
invite
recent-documents
mongomapper
cxxtest
dmx512
mirah
kdbg
sustainable-pace
mediarss
msdev
mdac

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