I am trying to handle ajax validation within <div class="b"> which is is partially rendered by using ajax…

$('.a').click(function(event){
$.ajax({
url: '<?php echo Yii::app()->createUrl('myController/myAction'); ?>',
type: "POST",
success: function( data ) {
$('.b').html(data);
}
});
});
in controller:
public function actionMyAction()
{
$form = new MyForm;
if(isset($_POST['MyForm']))
{
$form->attributes=$_POST['MyForm'];
if($form->validate())
{
...
$this->refresh();
}
}
$this->renderPartial('myView', array('myForm'=>$form));
}
If I use use render instead of renderPartial it works as intended. What am I missing?
Any help would be appreciated.
My friend helped me to solve this. Here’s his solution:
Rendering result should be postprocessed using
processOutput. This method “postprocesses the output generated by render(). This method is invoked at the end of render() and renderText(). If there are registered client scripts, this method will insert them into the output at appropriate places. If there are dynamic contents, they will also be inserted. This method may also save the persistent page states in hidden fields of stateful forms in the page”.Whether rendering result will be postprocessed is defined by
$processOutputparameter which isfalseby default:renderPartial(string $view, array $data=NULL, boolean $return=false, boolean $processOutput=false)Instead of
you should call: