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

Yii2: Add 'user_id' when create a post
output of active view depends on the type of user
How to set-up different URLs for yii frontend and backend
Ecommerce/Classified template with Yii2
Yii2 field accessed only via magic method
How to add a css class to <td> tags in a kv- GridView class in Yii2
Capcha always show incorrect
Integration Reportico in Yii2 Projects
Yii2 : Subdirectory in yii2 not working
Yii2 KCFinder with CKEditor
Yii2 - validation compare acting strange
Updating composer throws exception Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist
Dynamic declaration of a model in Yii2
image are save in folder but not saved in database in yii2.0
how can i put sidebar menu in right side using yii2
Yii2 afterSave. Using changedAttributes show error

Categories

HOME
multithreading
comparison
json.net
hashmap
xmpp
getelementsbytagname
cmd
rubygems
c#-2.0
yum
flyway4
node-notifier
apache-cayenne
windows-azure-storage
messages
circuit
systemc
tibco-mdm
dynamic-featured-image
uninstall
fgetcsv
nhapi
xacml
bpel
nouislider
sql-server-2012-express
javascriptcore
http-get
calibre
android-kernel
picasso
dartium
bitbucket-pipelines
hockeyapp
unobtrusive-validation
unoconv
optix
avro4s
fedex
estimote
qcombobox
galleria
komodoedit
prolog-setof
theming
nodebb
sybase-asa
windows-iot-core-10
dynamics-sl
query-performance
yt-project
underscore.js-templating
plottable.js
gstreamer-0.10
lua-5.1
yaws
dataview
freelancer.com-api
ios8-today-widget
srand
ionic
lustre
csquery
asp.net-dynamic-data
cctv
codeigniter-routing
internet-connection
bitcoinj
yorick
didselectrowatindexpath
algebraic-data-types
page-layout
oam
excel-2003
eclipse-memory-analyzer
buster.js
dataadapter
mqx
smtp-auth
wsdl-2.0
nsnetservice
frameset
ohm
adk
mercurial-server
infobox
recent-documents
iphone-web-app
blitz++
digest-authentication
gamequery
dmx512
perfect-hash
privilege
paul-graham

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