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 set active user in API
Yii2 full calendar AjaxEvents not working properly
white color Issue after create thumbnail image in yii2
Creating a one-to-many relationship in Yii2
Handle Image update in yii2
Header and Footer missing in modal popup
Select2 Krajee widget - using modal and getting the id of the value
sjaakp/yii2-illustrated-behavior Yii2 extension for image not working
change the navigation bar url from yii2 without redirecting
Yii 2 - Conditional Assets?
How to get value of dropdown instead of id yii2
How can I access private value from object
How to add valueless attribute to <form> tag using yii2 ActiveForm
Register a js file independently in Assets
Get user's email from twitter login in yii2
get Attribute Label in yii2

Categories

HOME
winforms
asp.net-core
netsuite
reflection
read-eval-print-loop
programming-languages
spring-cloud-stream
sqlite3
convolution
qore
virtualization
quickbooks
vaadin7
ghc
pugjs
flux
nhibernate-envers
fish
rst2pdf
opentype
atlassian-crucible
kendo-datasource
quote
phonegap
oracle-fusion-middleware
scorm2004
column-family
asset-pipeline
azure-sql-database
android-nestedscrollview
mapdb
impersonation
squib
jvm-languages
password-encryption
arena-simulation
s
auto-update
osx-mavericks
zip4j
typescript1.8
tropo
colorama
google-perftools
sybase-asa
color-profile
dynamics-sl
webdriverjs
migradoc
visual-c++-2008
removechild
multi-level
transmitfile
django-debug-toolbar
holder.js
associative-array
qtableview
qdialog
retina
wordml
iis-arr
embedded-code
service-accounts
unity5.2.3
skos
jsapi
codeigniter-url
file-copying
fpml
cctv
titanium-modules
rdl
article
yorick
dealloc
apc
flash-builder4.5
file-locking
excel-2003
sharp-repository
smtp-auth
selected
libstdc++
google-email-migration
pysimplesoap
errai
reddot
gwt-ext
external-accessory
vdsp
sql-server-profiler
paster
jquery-ui-droppable
nsviewanimation
virtual-functions
multiple-languages
uiq3

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