yiisoft / jquery-pjax

pushState + ajax = pjax
http://pjax.herokuapp.com
MIT License
143 stars 40 forks source link

Problem with nested PJax. Fix. #70

Open andrew-svirin opened 5 years ago

andrew-svirin commented 5 years ago

I have a problem with nested pjax. I need to specify directly pjax-container in code. Because my code is blowing and become unreadably by overriding native pjax behaviours.

bower-asset.jquery.pjax.js.patch.txt

yii2-pjax.patch.txt.txt

The main goal of these patches are:

  1. Allow to specify pjax container for response by pjax-data attribute.
  2. Disallow bind events on elements inside nested containers.
  3. I tried to fight with multiple form submission on trigger form submit, but i found that pjax is good with this and closing submitted previous forms. So in Network is seen as posts gone, but in real sent only last. I have tried to add attribut on container when it pjax-processing and refuse next triggering, but failed, so i decided that pjax is good with multiple form submission.
samdark commented 5 years ago

@AndriySvirin would you please make a pull request instead?

andrew-svirin commented 5 years ago

@samdark thanks a lot for answer, sorry i can not create pull request, i hope in future github will support simple pathces for propose changes. I using cweagans/composer-patches to apply patches.

I know that Pjax in Yii is not realized very well, exactly with nesting containers. Hope in next Yii3 version you will figure out with that, and i recommend to make some probes on old Yii2 versions to have some expirience.

Pjax is looks good for programming on PHP and code is readable until you need to make them nesting =) I think that Pjax widget should/could or unbind already binded events inside container response or avoid bind twice on same container event those are duplicates.