Hello comunity of yii, glad to programm on this great framework.
i got a problem with ajax
so i need widget with variable witch will increase on 1 on every ajax request, but it increase on 1 only on first request.
my controller
public function actionAjaxTest() {
$valuetestcontr=$_GET['value']+1;
$this->renderPartial('application.widgets.views.test',array('params' => array('value'=>$valuetestcontr)));
}
widget
class TestWidget extends CWidget {
public $params = array(
'action'=>'index',
);
public function init() {
}
public function run() {
$valuewidg = $this->params['value'] + 1;
if(isset($_GET['value']))
$valuewidg = $this->params['value']+2;
$this->render('test',array('params' => array('value'=>$valuewidg)));
}
}
view of widget
<?php
$valuetest=$params['value'] + 1;
echo '<div id=ajaxtest> value = '. $valuetest;
echo CHtml::ajaxLink(
'<i class="icon-chevron-left"></i>',
Yii::app()->createUrl(Yii::app()->controller->id . '/ajaxTest'), //<-CONTROLLER
array(
'type'=>'GET',
'data'=>array(
'value' => $valuetest,
),
'update' => '#ajaxtest'
)
);
echo '</div>';
and widget call in controller view
$this->widget('testWidget', array('params'=>array('value'=>1)));
i stucked with it from july, need to finish till NY, so will be glad on any response, thx.