0
나는 yii2에 breadcumbs 있습니다. 문제는 pjax를 사용하여 데이터베이스에 내 테이블을 무겁게 처리하는 것입니다.아약스에 breadcumbs 처리 yii2
하자이가 (보기의 index.php에서) 내 코드입니다, 말 : 아약스없이,
<?php
$this->title = 'Barangs';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="barang-index">
<?php
Pjax::begin([
'timeout' => 5000,
'id' => 'pjax-gridview'
]);
?>
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a('Create Barang', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?=
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'NO_URUT',
'CONSIGNEE',
'CONTAINER',
'SIZE',
'COIL_NO',
'NET',
'GROSS',
'CONTRACT_NO',
'KET',
'NAMA_FILE',
'TGL_UNSTUFF',
['class' => 'yii\grid\ActionColumn',
'buttons' => [
'view' => function($url, $model) {
$icon = '<span class="glyphicon glyphicon-eye-open"></span>';
return Html::a($icon, $url);
},
'update' => function($url, $model) {
$icon = '<span class="glyphicon glyphicon-pencil"></span>';
return Html::a($icon, $url);
},
'delete' => function($url, $model) {
$icon = '<span class="glyphicon glyphicon-trash"></span>';
return Html::a($icon, $url, [
"class" => 'pjaxDelete'
]);
},
]
],
],
]);
?>
<?php $this->registerJs('
/* fungsi ini akan dijalankan ketika class pjaxDelete di klik */
$(".pjaxDelete").on("click", function (e) {
/* cegah link menjalankan default action */
e.preventDefault();
if(confirm("Are you sure you want to delete this item?")){
/* request actionDelete dengan method post */
$.post($(this).attr("href"), function(data) {
/* reload gridview */
$.pjax.reload("#pjax-gridview",{"timeout":false});
});
}
});
');
?>
<?php Pjax::end(); ?></div>
내 질문은, breadcumbs는 Home/Barangs/Create Barang
표시됩니다. 그러나 아약스에서 빵가루는 이것을 보았습니다. Home/Barangs /
여전히 첫 번째 breadcumbs 형식이 필요합니다.
알려 주시기 바랍니다.
를 해결하는 문제는 다음 이동 경로는 다음과 같습니다 홈/Barangs –
코드 < ? = Html :: a ('Barang 만들기', [ 'create'], [ 'class'=> 'btn btn-success']?>)는 생성보기에 대한 링크를 생성합니다. –