【问题标题】:yii2 pjax inside other pjaxyii2 pjax 在其他 pjax 中
【发布时间】:2017-07-18 13:40:26
【问题描述】:

我有两个 pjax 的表单。 (一内二)当点击第二个 PJAX 中的链接时,向服务器发送查询,但在“X-PJAX-Container”字段中写入 ID 第一个容器。

Pjax::begin([
    'id' => 'register-form'
    ]);

...

Pjax::begin([
    'id' => 'que'
    ]);

echo yii\helpers\Html::a('update', ['/portal/que/gr-usl/');

Pjax::end();

...

Pjax::end();

点击更新后的位置:/portal/que/gr-usl?_pjax=%23register-form

请求头

X-PJAX:true
X-PJAX-Container:#register-form
X-Requested-With:XMLHttpRequest

如果为链接 #que 设置 data-pjax 请求标头未更改。

【问题讨论】:

    标签: yii2 pjax


    【解决方案1】:

    对于 pjax 禁用数据-pjax 中的所有链接,将 href 更改为 onclick 功能

    $.pjax({url: $(el).attr('link'), container: '#pjax-grusl'});
    

    链接有代码

    echo yii\helpers\Html::a('update', null,[
            'data-pjax' => 'false',
            'link' => \yii\helpers\Url::to(['/portal/que/gr-usl/',
                'ids'    => $ids,
                'filter' => $filter,
                'gr'     => $gr
            ]),
            'onclick' => 'selGr(this)'
        ]);
    

    但它应该在盒子里工作:(我不明白为什么点击链接没有从 dom 树中找到第一个 pjax 容器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-23
      • 2012-04-17
      • 2018-02-11
      相关资源
      最近更新 更多