How can I convert the text TbButton bootstrap into CHtml::link in Yii? below is the TbButton bootstrap code:
$this->widget('bootstrap.widgets.TbButton', array(
'label'=>'Data Protection Policy - Must Read for Consultant',
'type'=>'primary', // '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
'htmlOptions'=>array('class'=>'addContactBtn','onclick'=>'js:(function(){
$("#pdpaModal").modal({"show":true});
return false;
})();')));
I need to convert the code above into CHtml:
CHtml::link("Change Status", "#", array("onClick"=>"(function(){
$("#pdpaModal").modal({"show":true});
return false;
})();"))
However, I get an error on the onClick part. Can anyone help me to fix it? Thanks.
You need to escape double quote within double quote.
Either:
CHtml::link("Change Status", "#", array("onClick"=>"(function(){
$(\"#pdpaModal\").modal({\"show\":true});
return false;
})();"));
or
CHtml::link("Change Status", "#", array("onClick"=>'(function(){
$("#pdpaModal").modal({"show":true});
return false;
})();'));