Yii
4
Вклад в тег
use yii\widgets\Pjax;
use yii\widgets\PjaxAsset;
PjaxAsset::register($this);
$this->registerJs(<<<JS
$(document).on('change', '#provider', function(e) {
$.pjax({
timeout: 4000,
url: $('#filter-form').attr('action'),
container: '#list-view',
fragment: '#list-view',
data: {provider: this.options[this.selectedIndex].value},
});
});
JS
, yii\web\View::POS_END);
<?=Html::beginForm(Url::current(), 'GET', ['id'=>'filter-form']);?>
<?=Html::activeDropDownList($model, 'provider', Provider::items(), ['id'=>'provider']); ?>
<?=Html::endForm(); ?>
<?php \yii\widgets\Pjax::begin(); ?>
<?= \yii\widgets\ListView::widget([.....]) ?>
<?php \yii\widgets\Pjax::end(); ?>
server {
listen 80;
server_name example.ru;
root /home/example/data/www/example.ru;
index index.html index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$args;
}
location /admin {
try_files $uri $uri/ /admin.php?$args;
}
location ~ \.php$ {
root /home/example/data/www/example.ru;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/example/data/www/example.ru$fastcgi_script_name;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
public function createAction($id)
{
if ($id === '') {
$id = $this->defaultAction;
}
$actionMap = $this->actions();
if (isset($actionMap[$id])) {
return Yii::createObject($actionMap[$id], [$id, $this]);
} elseif (preg_match('/^[a-zA-Z0-9\\-_]+$/', $id) && strpos($id, '--') === false && trim($id, '-') === $id) {
$methodName = 'action' . str_replace(' ', '', ucwords(implode(' ', explode('-', $id))));
if (method_exists($this, $methodName)) {
$method = new \ReflectionMethod($this, $methodName);
if ($method->isPublic() && $method->getName() === $methodName) {
return new \yii\base\InlineAction($id, $this, $methodName);
}
}
}
return null;
}
[
'class'=>'yii\grid\DataColumn',
'attribute'=>'name',
'format'=>'raw',
'value'=>function ($model, $key, $index, $column) {
return a($model->name, ['update','id'=>$model->name], ['data-pjax'=>0]);
},
'contentOptions'=>[
'class'=>'edit-link',
],
],