D
D
Dmitry Kim2016-04-21 14:03:13
Yii
Dmitry Kim, 2016-04-21 14:03:13

YII2 and pjax. How to update one pjax after another is running?

The page has a Listvew wrapped in Pjax[id = list-pjax] .
There is also a modal window Modal[id = my-modal] , inside which there is a form wrapped in another Pjax[id=form-pjax] .
It also has the following javascript:

$('#form-pjax').on('pjax:end', function(){
  $('#my-modal').modal('hide');
  $.pjax.reload('#list-pjax');
});

I open the chrome debugger, pull the form, it works, the data is sent to the server, the server accepts it and everything works fine (phpstorm + xdebug), but Listview-pjax is updated from the browser cache. How to force it to be updated from the server?
PS: if you put disablecache in the network tab of the chrome developer panel, then everything works without problems.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
matperez, 2016-04-21
@kimono

Try this: $.pjax.reload('#list-pjax', {cache: false});

L
LAV45, 2016-04-22
@LAV45

Try to use in place Pjax , AjaxCreate
This widget just helps to work with small forms in a modal window. After the form has successfully saved, it reloads its container.
The only thing you have to change is Widget::$autoIdPrefix = 'x';because the id of some blocks in the modal window may overlap with those that are already on the page and js will not always work correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question