Jquery 如何动态更改CController::createUrl()的属性
我想访问隐藏字段值并动态分配给Jquery 如何动态更改CController::createUrl()的属性,jquery,yii,Jquery,Yii,我想访问隐藏字段值并动态分配给cityid。您可以在源文档中使用javascript回调的第三个选项 未测试@Joginder Sharma它有效吗?抱歉,没有时间测试..如果是,请接受答案..) $this->widget('zii.widgets.jui.CJuiAutoComplete', array( 'name'=>'searchlocation', 'id'=>'searchlocation', 'value'=>
cityid
。您可以在源文档中使用javascript回调的第三个选项
未测试@Joginder Sharma它有效吗?抱歉,没有时间测试..如果是,请接受答案..)
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'name'=>'searchlocation',
'id'=>'searchlocation',
'value'=>'',
'source'=>CController::createUrl('/home/findLocation',
array(
'cityid' => 'js: $('#hiddenField').val()',
)
),
'options'=>array(
'showAnim'=>'fold',
'minLength'=>'1',
'select'=>'js:function( event, ui ) {
$("#searchlocation").val( ui.item.label );
$("#hiddenlocationid").val( ui.item.location_id );
return false;
}',
),
'htmlOptions'=>array(
'onfocus' => 'js: this.value = null;
$("#searchlocation").val(null);
$("#hiddenlocationid").val(null);',
'class' => 'input-xxlarge search-query',
'placeholder' => "Your Location",
),
));
'source'=>
CJavaScriptExpression::code(
"$.getJSON(
".CController::createUrl('/home/findLocation').",
{cityid: $('#hiddenField').val()}
function(data) { return data; }
)",
),