When you try to load pjax grid it returns
Uncaught TypeError: Cannot read property 'push' of undefined
at jquery.pjax.js:981
at jquery.pjax.js:991
jquery.js:3860 jQuery.Deferred exception: jQuery(...).pjax is not a function TypeError: jQuery(...).pjax is not a function
Here is description of the problem - https://github.com/defunkt/jquery-pjax/issues/634.
May be it is not a bad idea to upgrade current jquery.pjax.js in yii2-pjax to latest version which is compatible with jQuery 3.x
| Q | A
| ---------------- | ---
| Yii version | 2.0.13-dev
| PHP version | 7.0.20
| Operating system | Linux
We have some custom changes in our fork but overall it's a good idea to update it.
@samdark is there any log of what functionality was added?
Having an unmaintained fork is not ideal.
Compatibility there is actually fixed so either I can tag it as without merging upstream...
https://github.com/yiisoft/jquery-pjax/blob/master/CHANGELOG.md
@samdark I still have some error with yiisoft/jquery-pjax
master
https://github.com/yiisoft/yii2/issues/14844#issuecomment-330237127
Only first directly redirect can be fixed, not all redirect fixed. After pjax reload the page full reload too (2x request).
OK. Then we need to merge upstream...
Hello, so what is happening i have now in bower dir jquery 3+ but pjax is old version and it is does not work. I use it on live project, what solution?
If you have time to handle upstream merging, please do a pull request.
so what is the the solution to fix that?
i have in vendor\bower\jquery all updated to jquery 3.2.1,
to pass the error i did add in config:
'yii\web\JqueryAsset' => [
'sourcePath' => null, // do not publish the bundle
'js' => [
'//ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js',
]
],
but it works in forms only not in grid
how to downgrade jquery to have my app working?
@enderr I also have a problem with new version off jquery.pjax.js. #59
I downgraded by putting : "yiisoft/yii2": "2.0.12" in my composer.json file
even if i pull directly pjax.js from last version of yii-pjax repo to vendor - i got unexpected behavior.
@claudejanz I did that and now don't have that error, but now not all scripts are working, when click on pencil in grid to edit a record i get the "loading" plaing forever, even if the url is changed in the addess bar
@EndErr do your "pencil link" have data-pjax="0"?
@claudejanz ActionColumn, doesn't work properly with generic jquery.pjax.js . It's possible that there are some custom changes to yii2-pjax/jquery.pjax.js.
Resolved by https://github.com/yiisoft/jquery-pjax/commit/047a0b08c9eb4f23b9dfb3a5bdabdfd0d52e5917
Will tag a release soon
@SilverFire
https://github.com/yiisoft/jquery-pjax/blob/047a0b08c9eb4f23b9dfb3a5bdabdfd0d52e5917/jquery.pjax.js#L24
new line missing
It was fixed afterwards
https://github.com/yiisoft/jquery-pjax/blob/master/jquery.pjax.js#L24
@claudejanz no, it has not any data-pjax attribute
even after update of yii2 and pjax not all scripts are working, including actions in grid and others included in code
@EndErr could you elaborate, please?
@SilverFire last week I had a working app with grids with actions and some custom actions for selected rows in grid, and forms with some scripts for dynamic data loaded with ajax.
After update this week the problems began to apear. First: grid's actions not working, if click on them the loading displays forever. Then scripts in forms (those ones for dynamic data and ajax) no more working, same loading forever. The custom actions for grid selected rows not working too, like nothing is there, inspecting dom I see the scripts and also the events but nothing works.
Can not reproduce. Are you sure you have received Pjax 2.0.7 update?
Execute these commands, please, and post output here:
composer show | grep pjax
find . -name 'jquery.pjax.js' | xargs md5sum
@SilverFire
`
composer show | grep pjax
find . -name 'jquery.pjax.js' | xargs md5sum
f4afbc8cf7ac64f99c677ec5b31175fe ./vendor/bower/yii2-pjax/jquery.pjax.js
f4afbc8cf7ac64f99c677ec5b31175fe ./backend/assets/9f85dede/jquery.pjax.js
`
Could anybody, who reported the issue, check whether it is fixed or not?
Everything works fine with Pjax 2.0.7, if there are any problems I will report it here.
any solutions? my scripts not working at all, assets are loaded but events not reacting
@EndErr problem still alive? You delete from cache all of old versions of your pages?
@bscheshirwork cleaned all assets, how to clean from cache old versions?
@EndErr for example
cli
command ./yii cache/flush-all
if you use
yii\caching\FileCache
(default, seecommon/config/main.php
inadvanced
template)
add to components (tocommon/config/main.php
or toconsole/config/main.php
)
'components' => [
'cache' => [ //for current apps
'class' => 'yii\caching\FileCache',
],
'cacheFrontend' => [ //directly for frontend web apps
'class' => \yii\caching\FileCache::class,
'cachePath' => Yii::getAlias('@frontend') . '/runtime/cache'
],
'cacheBackend' => [ //directly for frontend web apps
'class' => \yii\caching\FileCache::class,
'cachePath' => Yii::getAlias('@backend') . '/runtime/cache'
],
...
cache/*
manually from all runtime
dirsadvanced
template is a backend/runtime/cache
, console/runtime/cache
, frontend/runtime/cache
@EndErr problem still alive?
the problem is that all the custom scripts not working, those added in assets, those added in custom columns in grids (popover for example), and even from AdminLTE backend
@EndErr may be yours custom script uses old notation of pjax directly?
2.0.0
This release brings jQuery 3.x compatibility.
The value of container parameter to pjax functions should be a string selector, and not a jQuery object anymore. (backwards incompatible)
The value of container parameter cannot be a DOM node with an ID anymore. (backwards incompatible)
The call signature $("#main").pjax("a") is not supported anymore because the container selector #main cannot be inferred from the context of the $.fn.pjax() call. To fix this, pass the container selector explicitly: $("#main").pjax("a", "#main") (backwards incompatible)
@bscheshirwork did not use any pjax notation scripts, simple jquery for ajax requests without any pjax in code
@EndErr Can you get example of your user (broken) script? May be user script not support jQuery 3.x, only support jQuery 2.x?
Most helpful comment
Resolved by https://github.com/yiisoft/jquery-pjax/commit/047a0b08c9eb4f23b9dfb3a5bdabdfd0d52e5917
Will tag a release soon