vasireddy
(Kiranvasi)
September 18, 2011, 1:04pm
1
Dear All,
In CJuiAutoComplete I am displaying "Search" as a default value and clicking on autocompleate text field I want to clear that text . I tried using "click" but it is not working . Could any one please suggest me the solution ?
<?php
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'name'=>'test1',
'value' =>'Search',
'source'=>'js: function(request, response) {
$.ajax({
url: "'.$this->createUrl('myAutoComplete/autoCompleate').'",
dataType: "json",
data: {
term: request.term,
brand: $("#type").val()
},
success: function (data) {
response(data);
}
})
}',
'options' => array(
'showAnim' => 'fold',
'select' => 'js:function(event, ui){ alert(ui.item.value) }',
'click'=>'js:function( event, ui ) {
alert("This is a test");
}',
),
));
?>
Regards
Yii fan
mukeshsoni
(Mukeshsoni)
September 18, 2011, 6:26pm
2
Dear All,
In CJuiAutoComplete I am displaying "Search" as a default value and clicking on autocompleate text field I want to clear that text . I tried using "click" but it is not working . Could any one please suggest me the solution ?
<?php
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'name'=>'test1',
'value' =>'Search',
'source'=>'js: function(request, response) {
$.ajax({
url: "'.$this->createUrl('myAutoComplete/autoCompleate').'",
dataType: "json",
data: {
term: request.term,
brand: $("#type").val()
},
success: function (data) {
response(data);
}
})
}',
'options' => array(
'showAnim' => 'fold',
'select' => 'js:function(event, ui){ alert(ui.item.value) }',
'click'=>'js:function( event, ui ) {
alert("This is a test");
}',
),
));
?>
Regards
Yii fan
try the ‘focus’ event instead of click
vasireddy
(Kiranvasi)
September 18, 2011, 8:04pm
3
Thank You Mukesh but unfortunately even focus is not working . Focus only gets activated when I try to select one one of the options in autocompleate ( I mean the focus is for the items display in the list for auto compleate )
Could you please correct me if I am wrong ?
Regards
Yii Fan
mukeshsoni
(Mukeshsoni)
September 19, 2011, 8:00am
4
Why don’t you try using the onFocus attribute in htmlOptions, instead of options -
'htmlOptions=>array('onFocus'=>'js:function( event, ui ) {
alert("This is a test");
}', )
vasireddy
(Kiranvasi)
September 19, 2011, 12:10pm
5
Thank You Mukesh for this hint Finally the below code worked
'htmlOptions' => array(
'onFocus' => 'document.getElementById("searchAuto").value=""'
)
I think js:function( event, ui ) won’t work in htmlOptions …
Once again thank you
Regards
Yii Fan
apaoww
(Apa Oww)
May 22, 2014, 1:26am
6
Thank You Mukesh for this hint Finally the below code worked
'htmlOptions' => array(
'onFocus' => 'document.getElementById("searchAuto").value=""'
)
I think js:function( event, ui ) won’t work in htmlOptions …
Once again thank you
Regards
Yii Fan
Why don’t use
'htmlOptions' => array(
'placeholder'=>'Search',
),
It much easier.