how to load and execute new javascript when using ajax to refresh part of page

I used ajax request to partially render a div. Ajax response can be filled into div successfully but the newly registered script on ready event didn’t get executed. The following code was used in the view which was used for handling ajax request.



View: ajax


alert(‘this is a test’);


Yii::app()->getClientScript()->registerScript(‘my-script’, $script, CClientScript::POS_READY);

is there any way to do that?

renderPartial default is not going to generate js script

your have to set 4th param to be true, and it will work

go and see class reference :)

It works! Thanks a lot for your help! Yeah, the class documentation clearly states that.