a CHtml::link question

Events in htmlOptions in Chtml::link method is converted to html entites .

for example :


echo CHtml::link("Rate this","#",$htmlOptions = array('onclick'=>'$("#writerating").focus()'));

generates :

[html]<a onclick="$(&quot;#writerating&quot;).focus()" href="#">Rate this</a>[/html]

any idea how can i solve it ?

Thanks

Golan

Hi ghadad

You should probably separate your html tags and your jQuery code:


echo CHtml::link("Rate this","#",array('id'=>'target'));

and then somewhere in your view:




Yii::app()->clientScript->registerScript(

  'someName',

  '$("#target").click(function() {

    $("#writerating").focus();

  });'

);



Thank you dito .

I’ll use that . sometimes you want to write the code “on the fly” .