Reputation: 1
How do I include a PHP variable in a CJuiAutoComplete jquery? My sample below was not successful. Sorry for my bad English.
<?php
echo $count=$t['id'];
$this->widget('zii.widgets.jui.CJuiAutoComplete',
array(
'model'=>$model,
'attribute'=>"jwtn".$t["id"],
'sourceUrl'=>$this->createUrl('KemsainsCalon/lookup'),
'htmlOptions'=>array('placeholder'=>$model->isNewRecord ? "Nama ahli" : "ok"),
'options'=>
array(
'showAnim'=>'fold',
'select'=>"js:function(parsoalan, ui) {
// below is my problem, #KemsainsCalon_jwtn_id<?php echo $count?>, how do I concat php variables in jquery
$('#KemsainsCalon_jwtn_id<?php echo $count?>').val(ui.item.id);
}"
),
'cssFile'=>'jquery-ui.css',
));
?>
`
Upvotes: 0
Views: 801
Reputation: 14860
You can handle $count
like you would in a normal php string. select
may be javascript code but it's still a php string for now.
...
'select'=>"js:function(parsoalan, ui) {
$('#KemsainsCalon_jwtn_id".$count."').val(ui.item.id);
}"
Upvotes: 1