Fórumok

Single auto complete function in aui for multiple input fields with same cl

Swetha Harshini, módosítva 9 év-val korábban

Single auto complete function in aui for multiple input fields with same cl

New Member Bejegyzések: 24 Csatlakozás dátuma: 2014.06.16. Legújabb bejegyzések
I have been trying use the same auto complete function for below two input fields.

<aui:input name="report_sup_name" id="report_sup_name"
label="Name" inlineLabel="left" cssClass="su_auto" >
</aui:input>
<aui:input name="report_sub_name" label="01_name" inlineLabel="left"
showRequiredLabel="false" cssClass="su_auto" >


In the auto complete function I know where I am going wrong(emphasized in italic font). Since I gave inputNode as 'A.one(".className")' It is taking the first object from the list. The auto complete function should execute on onclick of any of the two input text fields

AUI().use('autocomplete-list','aui-base','aui-io-request-deprecated',
'autocomplete-filters','autocomplete-highlighters',function (A) {
var testData;
var node1=new A.AutoCompleteList({
allowBrowserAutocomplete: 'true',
activateFirstItem: 'true',
inputNode:A.one(".su_auto"),
render: 'true',
resultHighlighter: 'phraseMatch',
resultTextLocator:'firstName',
resultFilters:['phraseMatch'],
source:function()
{
inputValue=A.one(".su_auto").get("value");
var myAjaxRequest=A.io.request('<%=supervisorsAutoComplete.toString()%>',
{
dataType: 'json',
method:'POST',
data:{
<portlet:namespace />userEnteredText:inputValue,
},
autoLoad:false,
sync:false,
on: {
success:function(){
var data=this.get('responseData');
testData=data;
}
}
});
myAjaxRequest.start();
return testData;
},
});
node1.on('select',function(e)
{
var selected_node = e.itemNode,
selected_data = e.result;
A.one("#<portlet:namespace />supervisorId").set("value",selected_data.raw.id);
});
});

thumbnail
Nikhil Nishchal, módosítva 9 év-val korábban

RE: Single auto complete function in aui for multiple input fields with sam

Regular Member Bejegyzések: 177 Csatlakozás dátuma: 2012.06.22. Legújabb bejegyzések
Hello,
'A.one(".className")' return only one element, for using className, it returns the first element it found on DOM having this class.
For multiple element we use A.all().

For your case you may use, this method twice for both element.
Or, You may bind some click method on both element and pass the event.target to AutoComplete code.

Or, You may initialize once and the target can be change latter.
vel murugan, módosítva 6 év-val korábban

RE: Single auto complete function in aui for multiple input fields with sam

Junior Member Bejegyzések: 31 Csatlakozás dátuma: 2017.05.19. Legújabb bejegyzések
Nikhil Nishchal:
Hello,
'A.one(".className")' return only one element, for using className, it returns the first element it found on DOM having this class.
For multiple element we use A.all().

For your case you may use, this method twice for both element.
Or, You may bind some click method on both element and pass the event.target to AutoComplete code.

Or, You may initialize once and the target can be change latter.



For me also the same issue .I tried with A.all().It is not working in inputnode property. is there any other property for A.all()