2011-01-29

Ajax in Yii

<?php 
echo CHtml::textField(
 'serchfield',
 'start typing to filter...',
 array(
  'id'=>'input1',
  'class'=>'class1',
  'onkeyup'=>CHtml::ajax(
  array(
    'type'=>'POST',
    'url'=> Yii::app()->createUrl('//conv/convlist'),
    'update'=>'#data',
    'data'=>array('var'=>'123','serchfield'=>'js:jQuery(this).val()'),
    //'data'=> 'js:jQuery(this).serialize()',
   )
  ), 
  
  'onblur'=>"if (this.value == '') {this.value = 'start typing to filter...';}",
  'onfocus'=>"if (this.value == 'start typing to filter...') {this.value = '';}",
 )
);
?>
  
<div id="data" style='clear:both;'>
<?php 
 $this->renderPartial('//conv/_ajaxContent', array(
 'dataProviderConv'=>$dataProviderConv,
 )
 , false, true);  
?>
</div>
<?php endif; ?>