Yahoo autocomplete

I kinda got stuck trying to implement a YUI autocomplete text box. here is the code:

<div id="myAutoComplete"> 
<input id="myInput" type="text" /> 
<div id="myContainer"></div> 
</div>
<script type="text/javascript">
YAHOO.example.BasicRemote = function() {
oDS = new YAHOO.util.XHRDataSource("../User/Home2.aspx");
// Set the responseType
oDS.responseType = YAHOO.util.XHRDataSource.TYPE_TEXT;
// Define the schema of the delimited results
oDS.responseSchema = {
recordDelim: "\n",
fieldDelim: "\t"
};
// Enable caching
oDS.maxCacheEntries = 5;

// Instantiate the AutoComplete
var oAC = new YAHOO.widget.AutoComplete("myInput", "myContainer", oDS);
oDS.generateRequest = function(sQuery) {
return "../User/Home2.aspx?method=" + "SA&Id="+document.getElementById("lbAttributes")[document.getElementById("lbAttributes").selectedIndex].value +"&query="+sQuery;
};
oAC.queryQuestionMark =false;
oAC.allowBrowserAutoComplete=false;
 return {
 oDS: oDS,
 oAC: oAC
 };
}
</script>

I have added all the javascript yahoocript links and stylesheets, but it never seems to make an ajax call when I change the text in the myInput field and it doesn’t show anything ... I guess I missed something imp ...

+3
source share
2 answers

Honestly, and I know this is not the most useful answer ... you should study the use of jQuery these days as it has completely blown YUI out of the water in terms of ease of use, syntax and community.

Then you can go to http://plugins.jquery.com and find a whole bunch of cool autocomplete plugins with sample code, etc.

, .

0

@Kriss - , ? XHR, , .

@Adam - jQuery , , YUI . .

+3

All Articles