AjaxButton/AjaxLink howto?

Edit: ok, figured it out. Problem was this action function was protected instead of public.

Hi Guys,

I’m new both in yii and web dev, and have simple ajax question.

I have post model, and I’d like to create ajaxbuttons for voting up and down on this.

I wanted to do some tests but cant make it work, maybe you could help me.

In the views/post/_view.php I add something like this:


<?php echo CHtml::ajaxLink(

		'Vote UP',

		array('VoteUp'),

		array('update'=>'#test')

		); 

	?>

<div id="test">...</div>



Now in controllers/PostController.php I add actionVoteUp()


protected function actionVoteUp()

	{

		echo "LALALA";

		Yii:app()->end();

	}

But this div#test … is not changing to LALALA when I click link. What am I doing wrong?

Edit:

I get error:


<h1>CException</h1>

<p>PostController and its behaviors do not have a method or closure named "actionVoteUp". (C:\xampp\htdocs\yiiframework\framework\base\CComponent.php:266)</p><pre>#0 C:\xampp\htdocs\yiiframework\framework\web\actions\CInlineAction.php(50): CComponent->__call('actionVoteUp', Array)

#1 C:\xampp\htdocs\yiiframework\framework\web\actions\CInlineAction.php(50): PostController->actionVoteUp()

#2 C:\xampp\htdocs\yiiframework\framework\web\CController.php(309): CInlineAction->runWithParams(Array)

#3 C:\xampp\htdocs\yiiframework\framework\web\filters\CFilterChain.php(134): CController->runAction(Object(CInlineAction))

#4 C:\xampp\htdocs\yiiframework\framework\web\filters\CFilter.php(41): CFilterChain->run()

#5 C:\xampp\htdocs\yiiframework\framework\web\CController.php(1146): CFilter->filter(Object(CFilterChain))

#6 C:\xampp\htdocs\yiiframework\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))

#7 C:\xampp\htdocs\yiiframework\framework\web\filters\CFilterChain.php(131): CInlineFilter->filter(Object(CFilterChain))

#8 C:\xampp\htdocs\yiiframework\framework\web\CController.php(292): CFilterChain->run()

#9 C:\xampp\htdocs\yiiframework\framework\web\CController.php(266): CController->runActionWithFilters(Object(CInlineAction), Array)

#10 C:\xampp\htdocs\yiiframework\framework\web\CWebApplication.php(276): CController->run('VoteUp')

#11 C:\xampp\htdocs\yiiframework\framework\web\CWebApplication.php(135): CWebApplication->runController('post/VoteUp')

#12 C:\xampp\htdocs\yiiframework\framework\base\CApplication.php(162): CWebApplication->processRequest()

#13 C:\xampp\htdocs\pokerzysta\index.php(13): CApplication->run()

#14 {main}</pre>

Strange as PostController.php has this method declared :confused: