jquery script for CHtml::Button() is lost in Ajax render

The symptom is button doesn’t work in an ajax render.


    	<?php echo CHtml::Button('Join this company', 

                    	array('submit'=> Yii::app()->createUrl('user/join'))); 

    	?>

There should be short a script Yii generated at the end of the page to enable this button like this:




<script type="text/javascript"> /*<![CDATA[*/ jQuery(function($) 

{ jQuery('body').undelegate('#yt0','click').delegate('#yt0','click',function(){jQuery.yii.submitForm(this,'/vs/index.php?r=user/join',{});

return false;}); }); /*]]>*/ </script>

but due to button is echo out in an ajax render, so there is no jquery script output.

Through researching previous posts, I learned maybe CHtml::ClientChange() is the native way to solve this problem.

Is this correct?

If so, can you provide some examples? Due to my limited experience, I can’t learn how to use ClientChange() just by reading class reference.

Thank you!

got it!

You need to specify the last parameter of renderPartical() be true!

public string renderPartial(string $view, array $data=NULL, boolean $return=false, boolean $processOutput=false)