hefeng
(Hefengcui)
November 11, 2011, 9:31am
1
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.
Controller:
$this->renderPartial(‘ajax’);
View: ajax
$script=<<<HTMLL
alert(‘this is a test’);
HTMLL;
Yii::app()->getClientScript()->registerScript(‘my-script’, $script, CClientScript::POS_READY);
is there any way to do that?
pizwu
(Pizwu000)
November 11, 2011, 12:52pm
2
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
hefeng:
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.
Controller:
$this->renderPartial(‘ajax’);
View: ajax
$script=<<<HTMLL
alert(‘this is a test’);
HTMLL;
Yii::app()->getClientScript()->registerScript(‘my-script’, $script, CClientScript::POS_READY);
is there any way to do that?
hefeng
(Hefengcui)
November 11, 2011, 4:22pm
3
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.