H
H
hollanditkzn2017-05-26 11:28:57
Yii
hollanditkzn, 2017-05-26 11:28:57

How to make pjax order page auto refresh?

I used this example for pjax auto-update and I get the error syntax error, unexpected end of file
I didn’t understand a little what the problem is?

<?= Html::a('<span class="glyphicon glyphicon-refresh"></span>', ['zakaz/admin'], ['class' => 'btn btn-primary btn-lg pull-right', 'id' => 'refreshButtin']) 
<?= GridView::widget([
        'dataProvider' => $dataProviderNew,
        'tableOptions' => ['class' => 'table table-bordered'],
        'rowOptions' => function($model, $key, $index, $grid){
            return['id' => 'trNew'];
        },
        'columns' => [
            [
                'attribute' => 'id_zakaz',
                'headerOptions' => ['width' => '20'],
                'value' => 'prefics',
            ],
            [
                'attribute' => 'description',
                'contentOptions'=>['style'=>'white-space: normal;'],
            ],
            [
                'attribute' => 'srok',
                'format' => ['datetime', 'php:d.m.Y'],
                'value' => 'srok',
                'filter' => DatePicker::widget([
                     'model' => $searchModel,
                     'attribute' => 'srok',
                     'inline' => false, 
                    'clientOptions' => [
                    'autoclose' => true,
                    'format' => 'yyyy.mm.dd'
                ],
                ]),
                'headerOptions' => ['width' => '70'],
            ],
            [
                'attribute' => 'oplata',
                'headerOptions' => ['width' => '50'],
            ],
            [
                'attribute' => 'id_sotrud',
                'value' => 'idSotrud.name',
            ],
        ],
    ]); ?> 
<?php $script = <<< JS
    $(document).ready(function() {
      setInterval(function(){ $("#refreshButton").click(); }, 3000);
    });
    JS;
    $this->registerJs($script); ?>

How to do auto-update from database?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-05-26
@hollanditkzn

1. The <?= tag is not closed on the first line
2. There must be no spaces before the closing JS

<?php $script = <<< JS
    $(document).ready(function() {
      setInterval(function(){ $("#refreshButton").click(); }, 3000);
    });
JS;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question