why this code doesn't work?

Can someone explain why this code doesn’t work???

I made some html on site/index with ajax button. This ajax button works. It loads some html throug ajax and that html has another ajax button. This inner ajax button doesn’t work. Can someone explain why?

I have attached an archive where i demonstrate this error. It doesn’t need db, just web server. please take a look.

When using CHtml::ajaxButton(), yii creates the necessary javascript for you to make your ajax button work and inserts it into your html code once your run CController::render().

CController::renderPartial() though will not do this by default so you end up with a new button/link without any ajax javascript code for it. To force renderPartial() to process your javascript, you need to set the 4th parameter to true:

$this->renderPartial('ajax', array(), false, true);

You need to be aware though that doing this means that Yii will process your javascript code similar to how render() works (jquery will get loaded when needed, your ajax button code gets inserted, etc). I believe this also means that your code will end up triggering duplicate javascript code because yii will keep on creating the same event for the same ajax button, stacking up your click events. If you have your browser’s developer consoles up, you would see your ajax event triggered 1, 2, 4, 8, 16, etc times everytime you click on the ajax button