M
M
McMike2017-01-16 13:09:10
Yii
McMike, 2017-01-16 13:09:10

How pjax works?

Explain who is well versed in the issue.
In general, Pjax makes a request and receives the entire page in response, and then cuts out the block from it that needs to be noticed and replaces the old block with it, right?
It's not optimal at all. Versatile, but looks like a crutch, not a tool.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2017-01-17
@McMike

Pjax will receive what you pass. Pass a full page - it will take only a piece, pass only a piece - it will be more optimal. Pjax is a js script, it is not connected to the server and has no idea what is going on there. It waits for a response from which it is necessary to take a container with a certain selector.
Accordingly, in the action, you can separate the logic into pjax or regular get and return this or that.
At first, a lot of things confused me in it too, I did not understand its degree of integration into yii. The docks that are torn off from yii helped, specifically on the Pjax js plugin:
https://github.com/yiisoft/jquery-pjax
It came to an understanding that yii2 has a widget to work with it and nothing more, plus a verification method that I cited above. And in fact, deeper integration is not necessary.

M
Maxim Fedorov, 2017-01-16
@qonand

In general, Pjax makes a request and in response receives the entire page, and then cuts out of it the block to be replaced with and replaces the old block with it, right?

well, almost, only it receives the piece of code that you generate. This is not the whole page, it may be some fragment of it. Yes, this is not optimal - but you need to understand that this is primarily a universal tool for rapid development, on the basis of which you can make, for example, an MVP ... and if you need to do everything optimally, then you will need to write your code specifically for your task

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question