Closed SilverFire closed 9 years ago
@nkovacs I know you are familiar with pjax. Could you take a look, please?
Name sounds a bit too vague to me. The logic of the change is OK.
There were two other names, that I tried:
skipOuterPjax
: we are configuring pjax, there's no necessity in pjax
tieskipOuterContainers
: clear, but longWhen anyone has better name - please, text it!
skipOuterContainers
sounds much better to me even if it's longer.
Okay, let it be skipOuterContaiters
There are some fixes to nested containers and pjax's cache upstream. It's also possible Yii's widget is initializing the pjax code incorrectly.
There are some fixes to nested containers
Yeah, it's time to merge with origin. @samdark ?
It's also possible Yii's widget is initializing the pjax code incorrectly.
Why?
There are various ways to configure pjax, e.g. you can add data-pjax="container-selector" on links to specify a container instead of doing it in the $.pjax call. Maybe some combination of these makes nested containers work, and another breaks them. I'd try reproducing this with the upstream version, without Yii, first.
Looking at the pjax code: it calls preventDefault: https://github.com/defunkt/jquery-pjax/blob/master/jquery.pjax.js#L98 and it checks for isDefaultPrevented: https://github.com/defunkt/jquery-pjax/blob/master/jquery.pjax.js#L83
So the outer container should receive the event with isDefaultPrevented, and abort.
@nkovacs You think we should call event.preventDefault()
instead on return
here?
Will merge this if nobody complains
@nkovacs I checked it. It's not the same.
This PR adds
skipOuter
option.The use case:
I want to use a link inside
div#pjax-container
to navigate between pages with pushing URLs to the history. Every page displays some info and has a buttonCheck again
to update that info without page refresh or pushing to the browser history. As you see, I placed the button inside new container and defined a special config for it.Without out this PR, the config of
#pjax-status-container
is useless, because the network request of#pjax-status-container
will be immediately aborted by#pjax-container
. Then#pjax-container
will create his own request and process it according to it's rules.When
skipOuter = true
only the closest container will handle the request.The options defaults to false, so it doesn't break BC.