0

I have observed that when I execute the function:

Yii::$app->request->sendFile() within a row with a gridView, instead of launching the file, it shows it embedded in the HTML.

Then if I remove the Pjax::begin() and Pjax::end() borders that enclose the GridView, Then download works.

How can I work with both functionalities without losing one of them?

Mike Ross
  • 2,942
  • 5
  • 49
  • 101

1 Answers1

1

This was discussed at Yii2 the solution for now is to use this method:

<?php Pjax::begin([
    'id' => 'list',
    'linkSelector' => '#list a:not([data-pjax=0])'
 ]); ?>
<a href="#" id="customListener" data-pjax="0">custom js or simple link to your action with download</a>
<a href="some/link">pjax link</a>
<?php Pjax::end(); ?>

It looks like this feature may be included in future releases.

Serghei Leonenco
  • 3,478
  • 2
  • 8
  • 16
  • 1
    You don't have to explicitly define `linkSelector` for `data-pjax="0"` to work. It already works that way so just adding that to link is enough. – Michal Hynčica Nov 28 '19 at 12:25