나는 Yii를 처음 사용합니다. javascript 변수가 있습니다. 이 ID는 컨트롤러와 해당보기로 전달되어야합니다. 컨트롤러에서 JS 변수에 액세스 할 때 문제가 있습니다. 도와주세요. JS 변수가 전달되면 전달 된 변수를 어떻게 검사 할 것인가? 미리 감사드립니다, JS 변수 (ID)가 전달되는 곳에서JS 변수를 컨트롤러에 전달하고 Yii에서보기
내보기 :
<div style="float:left;padding-left:20px;">
<?php echo $form->labelEx($model,'host_customer_id'); ?>
<?php
echo $form->textField($model,'host_customer_id',array('style'=>'width:420px;'));
$this->widget('ext.select2.ESelect2', array(
'selector' => '#NimsoftHost_host_customer_id',
'options' => array(
'allowClear'=>false,
'placeholder' => 'Search Other Customers',
'minimumInputLength' => 3,
'quietMillis'=>100,
'ajax' => array(
'url' => Yii::app()->createUrl('Nimsoft/customers'),
'dataType' => 'jsonp',
'data' => 'js: function(term,page) {
return {
q: term,
//ctype: $("#itsmIncidents_cloudcustomer input:radio:checked").val(),
page_limit: 10,
};
}',
'results' => 'js: function(data,page){
return {results: data.details};
}',
),
'formatResult' => 'js:function(data){
return data.name;
}',
'formatSelection' => 'js: function(data) {
return data.name;
}',
),
));
?>
<div style="float:right;padding-left:10px;">
<?php
echo CHtml::link('view details', array('/Nimsoft/ciLink'), array(
'onclick'=>'return hs.htmlExpand(this, { objectType: "iframe", wrapperClassName: "full-size",height:500, align: "center" })',
'class'=>'btn btn-block btn-success',
'style'=>'width:100px;display:none;',
'id'=>'customer_details_pop',
));
?>
</div>
</div>
<?php $this->endWidget();?>
<script>
$("#NimsoftHost_host_customer_id").on("change", function(e) {
<?php echo CHtml::ajax(array(
'url'=>array('Nimsoft/loadCustType'),
'data'=> "js:{'NimsoftHost[host_customer_id]':e.val}",
'type'=>'post',
'dataType'=>'json',
'success'=>"function(data)
{
// enable customer link
$('#customer_details_pop').css('display','block');
$('#customer_details_pop').attr('href', 'Nimsoft/details/'+data.customerid);
} ",
))?>;
})
</script>
여기
내가 data.customerid을 전달하고있다. 이 값이 컨트롤러에 있는지를 알고 싶습니다. 그것이 간다면, 내 견해 (details.php)에서 그것을 인쇄하는 법.
내 컨트롤러 액션 :
public function actionDetails()
{
$this->render('details');
}
dat URL의 a.customerid는 세션 변수가 아닌 쿼리 문자열입니다. urlManager에 대해 알고 있습니까? – synapze
코드를 변경했습니다. 지금 말하십시오. – user3318138