Answer the question
In order to leave comments, you need to log in
Yii 2 ajax update?
I want to implement the same functionality as here des1roer.blogspot.ru/2015/04/yii-renderpartial.html
originally I have
<?php
use execut\widget\TreeView;
use yii\widgets\Pjax;
use yii\helpers\Html;
?>
<div class="main-default-index">
<?php
$items = [
[
'text' => 'Parent 1',
'nodes' => [
[
'text' => 'Child 1',
'nodes' => [
[
'text' => 'Grandchild 1'
],
[
'text' => 'Grandchild 2'
]
]
],
[
'text' => 'Child 2',
'href' => 'http://asutpdb.ru/362_363.php',
]
],
],
[
'text' => 'Parent 2',
]
];
$onSelect = new \yii\web\JsExpression(<<<JS
function (undefined, item) {
$.pjax({
container: '#pjax-container',
url: (typeof item.href != "undefined")? ""+item.href : '',
timeout: null
});
}
JS
);
echo $groupsContent = TreeView::widget([
'data' => $items,
'size' => TreeView::SIZE_SMALL,
'clientOptions' => [
'onNodeSelected' => $onSelect,
'selectedBackColor' => 'rgb(40, 153, 57)',
'borderColor' => '#fff',
],
]);
?>
<?php Pjax::begin(); ?>
<div id="pjax-container">sdfds</div>
<?php Pjax::end(); ?>
</div>
echo CHtml::ajaxLink(
$text = 'Click me',
array('req'),
$ajaxOptions=array (
'type'=>'POST',
'update'=>'#content',
'data' => array( 'id' => '44'),
),
$htmlOptions=array (
)
);
$onSelect = new \yii\web\JsExpression(<<<JS
function (undefined, item) {
$.ajax({
type: 'POST',
url : 'default/lol/?id=' + item.href,
update: '#pjax-container',
container: '#pjax-container',
// data: (typeof item.href != "undefined") ? item.href : '',
timeout: null
});
}
JS
);
public function actionLol($id)
{
$page = $id;
// $page = Page::model()->findByPk($page)->link;
echo '
<iframe id="ifr" src="' . $page . '" align="center">
</iframe>';
//return $this->render('index');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question