yiisoft / jquery-pjax

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

Nested pjax containers load content of external pjax container. #59

Closed claudejanz closed 7 years ago

claudejanz commented 7 years ago

Since jquery 3.* compatibility update, nested pjax containers load content of external pjax container. even if skipOuterContainers is set to true.

Pjax::begin([
    'id' => 'reservation-home',
    'clientOptions' => [
        'skipOuterContainers' => true,
    ],
]);
claudejanz commented 7 years ago

Full view exemple:

use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\Pjax;

Pjax::begin();
echo Html::a('external link', Url::current(), ['class' => 'btn btn-default']);

// internal block
Pjax::begin([
    'clientOptions' => [
        'skipOuterContainers' => true,
    ],
]);
echo Html::a('internal link', Url::current(), ['class' => 'btn btn-default']);
Pjax::end();

Pjax::end();

Works fine on yii 2.0.12 don't work correctly on 2.0.13

claudejanz commented 7 years ago

For a better see of what happens I added time to exemple:

use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\Pjax;

$date = new Datetime();

// external block
Pjax::begin([
    'clientOptions' => [
    ],
]);
echo Html::a('external link', Url::current(), ['class' => 'btn btn-default']);
echo Html::tag('p',Yii::$app->formatter->asDatetime($date));

// internal block
Pjax::begin([
    'clientOptions' => [
        'skipOuterContainers' => true,
    ],
]);
echo Html::a('internal link', Url::current(), ['class' => 'btn btn-default']);
echo Html::tag('p',Yii::$app->formatter->asDatetime($date));
Pjax::end();
// internal block end

Pjax::end();
// external block end
claudejanz commented 7 years ago

Solved since merge with latest from defunkt/jquery-pjax

SilverFire commented 7 years ago

Thank you